Fixing #1976 by allowing allocations between INT_MAX and SIZE_MAX and at the same...
authorChristian Grothoff <christian@grothoff.org>
Tue, 6 Dec 2011 14:13:38 +0000 (14:13 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 6 Dec 2011 14:13:38 +0000 (14:13 +0000)
src/datastore/gnunet-service-datastore.c
src/util/common_allocation.c
src/util/container_bloomfilter.c

index be88d288e46961f102d4068a65b156b5b9b7b7b9..327244ffd9b10398df62970bfda64e6987c72faa 100644 (file)
@@ -1492,7 +1492,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   cache_size = quota / 8;       /* Or should we make this an option? */
   GNUNET_STATISTICS_set (stats, gettext_noop ("# cache size"), cache_size,
                          GNUNET_NO);
-  bf_size = quota / 32;         /* 8 bit per entry, 1 bit per 32 kb in DB */
+  if (quota / 32LL > (1 << 31)) 
+    bf_size = (1 << 31);          /* absolute limit: ~2 GB, beyond that BF just won't help anyway */
+  else
+    bf_size = quota / 32;         /* 8 bit per entry, 1 bit per 32 kb in DB */
   fn = NULL;
   if ((GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_filename (cfg, "DATASTORE", "BLOOMFILTER",
index fd5e993e2fcdff4d72551df9e228bd3f9d8052fb..5e1f75eb7c78929becd694e02d64ab657a137222 100644 (file)
@@ -136,7 +136,6 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber)
     return NULL;
 #endif
 
-  GNUNET_assert_at (size < INT_MAX, filename, linenumber);
   result = malloc (size);
   if (result == NULL)
     return NULL;
index 180aab4c3ccbecc903f4d259fc62fc75b4d24db1..31e777dc360a8b6438c05aff38e0d7c88f3afe45 100644 (file)
@@ -463,7 +463,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
   if (size < BUFFSIZE)
     size = BUFFSIZE;
   ui = 1;
-  while (ui < size)
+  while ( (ui < size) &&
+         (ui * 2 > ui) )
     ui *= 2;
   size = ui;                    /* make sure it's a power of 2 */