Guard against bogus return value from strxfrm(). For instance Microsoft's
authorTor Lillqvist <tml@iki.fi>
Sat, 21 Aug 2004 13:43:51 +0000 (13:43 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sat, 21 Aug 2004 13:43:51 +0000 (13:43 +0000)
2004-08-21  Tor Lillqvist  <tml@iki.fi>

* glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
return value from strxfrm(). For instance Microsoft's strxfrm()
returns INT_MAX on errors. (#141124)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gunicollate.c

index 5d82166..bd25605 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-08-21  Tor Lillqvist  <tml@iki.fi>
+
+       * glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
+       return value from strxfrm(). For instance Microsoft's strxfrm()
+       returns INT_MAX on errors. (#141124)
+
 2004-08-19  Tor Lillqvist  <tml@iki.fi>
 
        * glib/gunicollate.c (g_utf8_collate, g_utf8_collate_key): Correct
@@ -120,7 +126,7 @@ Sun Aug  1 13:19:18 2004  Manish Singh  <yosh@gimp.org>
        to run_roundtrip_tests().
 
 2004-08-01 Matthias Clasen  <mclasen@redhat.com>
-                                                                                
+
        * Post-release version bump
 
         * === Released 2.5.1 ===
index 5d82166..bd25605 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-21  Tor Lillqvist  <tml@iki.fi>
+
+       * glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
+       return value from strxfrm(). For instance Microsoft's strxfrm()
+       returns INT_MAX on errors. (#141124)
+
 2004-08-19  Tor Lillqvist  <tml@iki.fi>
 
        * glib/gunicollate.c (g_utf8_collate, g_utf8_collate_key): Correct
@@ -120,7 +126,7 @@ Sun Aug  1 13:19:18 2004  Manish Singh  <yosh@gimp.org>
        to run_roundtrip_tests().
 
 2004-08-01 Matthias Clasen  <mclasen@redhat.com>
-                                                                                
+
        * Post-release version bump
 
         * === Released 2.5.1 ===
index 5d82166..bd25605 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-21  Tor Lillqvist  <tml@iki.fi>
+
+       * glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
+       return value from strxfrm(). For instance Microsoft's strxfrm()
+       returns INT_MAX on errors. (#141124)
+
 2004-08-19  Tor Lillqvist  <tml@iki.fi>
 
        * glib/gunicollate.c (g_utf8_collate, g_utf8_collate_key): Correct
@@ -120,7 +126,7 @@ Sun Aug  1 13:19:18 2004  Manish Singh  <yosh@gimp.org>
        to run_roundtrip_tests().
 
 2004-08-01 Matthias Clasen  <mclasen@redhat.com>
-                                                                                
+
        * Post-release version bump
 
         * === Released 2.5.1 ===
index 5d82166..bd25605 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-21  Tor Lillqvist  <tml@iki.fi>
+
+       * glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
+       return value from strxfrm(). For instance Microsoft's strxfrm()
+       returns INT_MAX on errors. (#141124)
+
 2004-08-19  Tor Lillqvist  <tml@iki.fi>
 
        * glib/gunicollate.c (g_utf8_collate, g_utf8_collate_key): Correct
@@ -120,7 +126,7 @@ Sun Aug  1 13:19:18 2004  Manish Singh  <yosh@gimp.org>
        to run_roundtrip_tests().
 
 2004-08-01 Matthias Clasen  <mclasen@redhat.com>
-                                                                                
+
        * Post-release version bump
 
         * === Released 2.5.1 ===
index 5d82166..bd25605 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-21  Tor Lillqvist  <tml@iki.fi>
+
+       * glib/gunicollate.c (g_utf8_collate_key): Guard against bogus
+       return value from strxfrm(). For instance Microsoft's strxfrm()
+       returns INT_MAX on errors. (#141124)
+
 2004-08-19  Tor Lillqvist  <tml@iki.fi>
 
        * glib/gunicollate.c (g_utf8_collate, g_utf8_collate_key): Correct
@@ -120,7 +126,7 @@ Sun Aug  1 13:19:18 2004  Manish Singh  <yosh@gimp.org>
        to run_roundtrip_tests().
 
 2004-08-01 Matthias Clasen  <mclasen@redhat.com>
-                                                                                
+
        * Post-release version bump
 
         * === Released 2.5.1 ===
index 9ca3a58..ff7ad3d 100644 (file)
@@ -231,6 +231,14 @@ g_utf8_collate_key (const gchar *str,
       if (str_locale)
        {
          xfrm_len = strxfrm (NULL, str_locale, 0);
+         if (xfrm_len < 0 || xfrm_len >= G_MAXINT - 2)
+           {
+             g_free (str_locale);
+             str_locale = NULL;
+           }
+       }
+      if (str_locale)
+       {
          result = g_malloc (xfrm_len + 2);
          result[0] = 'A';
          strxfrm (result + 1, str_locale, xfrm_len + 1);