summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2011-11-30 22:40:43 +0900
committersuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2011-11-30 22:40:43 +0900
commiteba2781ab98282714c19df4c758a140dc0cc33ad (patch)
treee0eae7593627df6681ff4109db724eff58cce7fb
parent628bebe639007244ebd7a8d17dfcb6555f04c61a (diff)
downloadfreetype2-eba2781ab98282714c19df4c758a140dc0cc33ad.tar.gz
[apinames] Fix the overflow of signed integer hash.
* src/tools/apinames.c (names_add): Change the type of `h' from int to unsigned int, to prevent undefined behaviour in the overflow of signed integers (overflow of unsigned int is defined to be wrap around). Found by clang test suggested by Sean McBride.
-rw-r--r--ChangeLog10
-rw-r--r--src/tools/apinames.c5
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f67d886eb..30e676273 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-11-30 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+ [apinames] Fix the overflow of signed integer hash.
+
+ * src/tools/apinames.c (names_add): Change the type of `h' from
+ int to unsigned int, to prevent undefined behaviour in the
+ overflow of signed integers (overflow of unsigned int is defined
+ to be wrap around). Found by clang test suggested by Sean
+ McBride.
+
2011-11-30 Werner Lemberg <wl@gnu.org>
[winfonts] Remove casts.
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index 0348e1ab3..80c92d4eb 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -59,8 +59,9 @@ static void
names_add( const char* name,
const char* end )
{
- int nn, len, h;
- Name nm;
+ unsigned int h;
+ int nn, len;
+ Name nm;
if ( end <= name )
return;