]> Savannah Git Hosting - gnulib.git/commitdiff
uniname/uniname-tests: integer overflow fix
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:26:25 +0000 (18:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:28:32 +0000 (18:28 -0700)
* tests/uniname/test-uninames.c (fill_names, fill_aliases):
Check for integer overflow.

ChangeLog
tests/uniname/test-uninames.c

index c1bf07eff00c6185ab70b04324bbfa7e11b5dc24..4585cf12bc1e8405217d7bb7183b52e795a0b3f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       uniname/uniname-tests: integer overflow fix
+       * tests/uniname/test-uninames.c (fill_names, fill_aliases):
+       Check for integer overflow.
+
        duplocale-tests: fix unlikely crash
        * tests/test-duplocale.c (get_locale_dependent_values):
        Don’t crash with absurdly long month names.
index dfa2c4230bbd8f240fec301326aeac98d965438d..476bb07f0509c8c1880e2562930cdc0702f22812 100644 (file)
@@ -64,6 +64,7 @@ fill_names (const char *unicodedata_filename)
       char *p;
       char *comment;
       unsigned int i;
+      unsigned long ul;
 
       lineno++;
 
@@ -94,12 +95,13 @@ fill_names (const char *unicodedata_filename)
           exit (EXIT_FAILURE);
         }
       *p = '\0';
-      i = strtoul (field0, NULL, 16);
-      if (i >= 0x110000)
+      ul = strtoul (field0, NULL, 16);
+      if (ul >= 0x110000)
         {
           fprintf (stderr, "index too large\n");
           exit (EXIT_FAILURE);
         }
+      i = ul;
       unicode_names[i] = xstrdup (field1);
     }
   if (ferror (stream) || fclose (stream))
@@ -132,6 +134,7 @@ fill_aliases (const char *namealiases_filename)
       char *p;
       char *comment;
       unsigned int uc;
+      unsigned long ul;
 
       comment = strchr (line, '#');
       if (comment != NULL)
@@ -161,12 +164,13 @@ fill_aliases (const char *namealiases_filename)
         }
       *p = '\0';
 
-      uc = strtoul (field0, NULL, 16);
-      if (uc >= 0x110000)
+      ul = strtoul (field0, NULL, 16);
+      if (ul >= 0x110000)
         {
           fprintf (stderr, "index too large\n");
           exit (EXIT_FAILURE);
         }
+      uc = ul;
 
       if (aliases_count == ALIASLEN)
         {