[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] uniname/uniname-tests: integer overflow fix
From: |
Bruno Haible |
Subject: |
Re: [PATCH 6/6] uniname/uniname-tests: integer overflow fix |
Date: |
Wed, 27 Sep 2017 02:01:20 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-93-generic; KDE/5.18.0; x86_64; ; ) |
> 2017-09-25 Paul Eggert <address@hidden>
>
> + uniname/uniname-tests: integer overflow fix
> + * tests/uniname/test-uninames.c (fill_names, fill_aliases):
> + Check for integer overflow.
Thanks, Paul. A small followup, to reduce the number of local variables:
2017-09-26 Bruno Haible <address@hidden>
uniname/uniname-tests: Tighten code.
* tests/uniname/test-uninames.c (fill_names, fill_aliases): Merge two
local variables into one.
diff --git a/tests/uniname/test-uninames.c b/tests/uniname/test-uninames.c
index 476bb07..46a9a91 100644
--- a/tests/uniname/test-uninames.c
+++ b/tests/uniname/test-uninames.c
@@ -63,8 +63,7 @@ fill_names (const char *unicodedata_filename)
{
char *p;
char *comment;
- unsigned int i;
- unsigned long ul;
+ unsigned long i;
lineno++;
@@ -95,13 +94,12 @@ fill_names (const char *unicodedata_filename)
exit (EXIT_FAILURE);
}
*p = '\0';
- ul = strtoul (field0, NULL, 16);
- if (ul >= 0x110000)
+ i = strtoul (field0, NULL, 16);
+ if (i >= 0x110000)
{
fprintf (stderr, "index too large\n");
exit (EXIT_FAILURE);
}
- i = ul;
unicode_names[i] = xstrdup (field1);
}
if (ferror (stream) || fclose (stream))
@@ -133,8 +131,7 @@ fill_aliases (const char *namealiases_filename)
{
char *p;
char *comment;
- unsigned int uc;
- unsigned long ul;
+ unsigned long uc;
comment = strchr (line, '#');
if (comment != NULL)
@@ -164,13 +161,12 @@ fill_aliases (const char *namealiases_filename)
}
*p = '\0';
- ul = strtoul (field0, NULL, 16);
- if (ul >= 0x110000)
+ uc = strtoul (field0, NULL, 16);
+ if (uc >= 0x110000)
{
fprintf (stderr, "index too large\n");
exit (EXIT_FAILURE);
}
- uc = ul;
if (aliases_count == ALIASLEN)
{
- [PATCH 1/6] parse-datetime, posixtm: avoid uninit access, Paul Eggert, 2017/09/25
- [PATCH 2/6] parse-datetime: fix dependency, Paul Eggert, 2017/09/25
- [PATCH 3/6] sys_types: update URL, Paul Eggert, 2017/09/25
- [PATCH 4/6] maint: fix overflow checking in nap.h, Paul Eggert, 2017/09/25
- [PATCH 5/6] duplocale-tests: fix unlikely crash, Paul Eggert, 2017/09/25
- [PATCH 6/6] uniname/uniname-tests: integer overflow fix, Paul Eggert, 2017/09/25
- Re: [PATCH 6/6] uniname/uniname-tests: integer overflow fix,
Bruno Haible <=
- Re: [PATCH 1/6] parse-datetime, posixtm: avoid uninit access, Thien-Thi Nguyen, 2017/09/26