commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd-l4/libhurd-ihash ihash.c ihash.h


From: Marcus Brinkmann
Subject: hurd-l4/libhurd-ihash ihash.c ihash.h
Date: Sun, 17 Aug 2003 00:16:09 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/08/17 00:16:09

Modified files:
        libhurd-ihash  : ihash.c ihash.h 

Log message:
        Fix prime table types.  Improve overflow check when finding the next 
prime
        number.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/libhurd-ihash/ihash.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/libhurd-ihash/ihash.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: hurd-l4/libhurd-ihash/ihash.c
diff -u hurd-l4/libhurd-ihash/ihash.c:1.2 hurd-l4/libhurd-ihash/ihash.c:1.3
--- hurd-l4/libhurd-ihash/ihash.c:1.2   Sun Aug 17 00:02:38 2003
+++ hurd-l4/libhurd-ihash/ihash.c       Sun Aug 17 00:16:09 2003
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <stdint.h>
 #include <assert.h>
 
 #include <hurd/ihash.h>
@@ -31,7 +32,7 @@
 
 /* The odd prime numbers greater than twice the last and less than
    2^40 (nobody needs more than 640 GB of memory).  */
-static const unsigned int ihash_sizes[] =
+static const uint64_t ihash_sizes[] =
 {
   3,
   7,
@@ -62,15 +63,15 @@
   359339171,
   718678369,
   1437356741,
-  2874713497,
-  5749427029,
-  11498854069,
-  22997708177,
-  45995416409,
-  91990832831,
-  183981665689,
-  367963331389,
-  735926662813
+  UINT64_C (2874713497),
+  UINT64_C (5749427029),
+  UINT64_C (11498854069),
+  UINT64_C (22997708177),
+  UINT64_C (45995416409),
+  UINT64_C (91990832831),
+  UINT64_C (183981665689),
+  UINT64_C (367963331389),
+  UINT64_C (735926662813)
 };
 
 
@@ -282,7 +283,10 @@
   for (i = 0; i < ihash_nsizes; i++)
     if (ihash_sizes[i] > old_ht.size)
       break;
-  if (i == ihash_nsizes)
+  if (i == ihash_nsizes
+      || ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_value_t)
+      || ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_key_t)
+      || ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_locp_t *))
     return ENOMEM;             /* Surely will be true momentarily.  */
     
   ht->size = ihash_sizes[i];
Index: hurd-l4/libhurd-ihash/ihash.h
diff -u hurd-l4/libhurd-ihash/ihash.h:1.1 hurd-l4/libhurd-ihash/ihash.h:1.2
--- hurd-l4/libhurd-ihash/ihash.h:1.1   Sat Aug 16 23:17:17 2003
+++ hurd-l4/libhurd-ihash/ihash.h       Sun Aug 17 00:16:09 2003
@@ -1,3 +1,4 @@
+typedef int error_t;
 /* ihash.h - Integer keyed hash table interface.
    Copyright (C) 1995, 2003 Free Software Foundation, Inc.
    Written by Miles Bader <address@hidden>.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]