fixes
authorChristian Grothoff <christian@grothoff.org>
Mon, 7 Sep 2009 11:58:04 +0000 (11:58 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 7 Sep 2009 11:58:04 +0000 (11:58 +0000)
22 files changed:
src/core/core_api.c
src/core/gnunet-service-core.c
src/datastore/gnunet-service-datastore.c
src/fs/fs_directory.c
src/fs/fs_download.c
src/fs/fs_search.c
src/fs/fs_unindex.c
src/fs/fs_uri.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/peerinfo_api.c
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c
src/util/configuration.c
src/util/crypto_hash.c
src/util/crypto_rsa.c
src/util/disk.c
src/util/getopt_helpers.c
src/util/os_installation.c
src/util/os_network.c
src/util/test_crypto_aes_weak.c
src/util/test_os_load.c
src/util/test_scheduler.c

index ac958449be8ea570bac70b6ce9b39054103ffbca..6aca886400c199a7a7323fdd64acc008d14dcf0b 100644 (file)
@@ -272,11 +272,9 @@ static void
 timeout_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CORE_TransmitHandle *th = cls;
-  struct GNUNET_CORE_Handle *h;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmission request timed out.\n");
-  h = th->ch;
   th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL));
   GNUNET_CORE_notify_transmit_ready_cancel (th);
index 4012ac3a86b4aa2f72efef0bcf8d38bc22e48eb1..d950237cde79f3cd74145e987b64429001222f15 100644 (file)
@@ -2918,7 +2918,6 @@ neighbour_quota_update (void *cls,
      account for possibility of new neighbours joining any time 
      AND to convert to double... */
   pref_rel = n->current_preference / (1.0 + preference_sum);
-  share = 0;
   distributable = 0;
   if (bandwidth_target_out > neighbour_count * MIN_BPM_PER_PEER)
     distributable = bandwidth_target_out - neighbour_count * MIN_BPM_PER_PEER;
index 87ae427e4cb1704f8020d66a50c6520868640492..900c1a8c8eec8cf7c370540b2e9a9195b2e3c046 100644 (file)
@@ -748,7 +748,6 @@ handle_release_reserve (void *cls,
          return;
        }       
       prev = pos;
-      pos = next;
     }
   GNUNET_break (0);
   transmit_status (client, GNUNET_SYSERR, gettext_noop ("Could not find matching reservation"));
index d67c6e8efadc463abbb8e0d133b717a372fa71bf..fa046b85842108ab2f0985d8767a446dc569c1b8 100644 (file)
@@ -335,7 +335,8 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
     fsize = 0; /* not given */
   if (fsize > MAX_INLINE_SIZE)
     fsize = 0; /* too large */
-  if (NULL != memchr (data, 0, fsize))
+  if ( (NULL == data) ||
+       (NULL != memchr (data, 0, fsize)) )
     fsize = 0; /* must not have 0's in data! */
   uris = GNUNET_FS_uri_to_string (uri);
   slen = strlen (uris) + 1;
@@ -524,12 +525,11 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
          sizes[i] = pos->len;
          pos = pos->next;
        }
+      block_align (size,
+                  bld->count,
+                  sizes,
+                  perm);
     }  
-  block_align (size,
-              bld->count,
-              sizes,
-              perm);
-
   /* compute final size with alignment */
   for (i = 0; i < bld->count; i++)
     {
@@ -563,9 +563,12 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
              sizes[i]);
       GNUNET_free (bes[i]);
     }
-  GNUNET_free (sizes);
-  GNUNET_free (perm);
-  GNUNET_free (bes);
+  if (bld->count > 0)
+    {
+      GNUNET_free (sizes);
+      GNUNET_free (perm);
+      GNUNET_free (bes);
+    }
   GNUNET_assert (off == size);  
   GNUNET_CONTAINER_meta_data_destroy (bld->meta);
   GNUNET_free (bld);
index 77fbb11399113a78fa0fa5feeab2da9d6f050a0e..9ab4c5ce0896850994c9e92ddeaa14968cd692bb 100644 (file)
@@ -669,8 +669,8 @@ GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h,
     return NULL;
   // FIXME: add support for "loc" URIs!
   GNUNET_assert (GNUNET_FS_uri_test_chk (uri));
-  if ( (dc->offset + dc->length < dc->offset) ||
-       (dc->offset + dc->length > uri->data.chk.file_length) )
+  if ( (offset + length < offset) ||
+       (offset + length > uri->data.chk.file_length) )
     {
       GNUNET_break (0);
       return NULL;
index fd7dcf6d967aa9fa3b036e5cfaf7b7872c145f9c..1a9fc699e00909f8d460a9ba18a76a224d1404e6 100644 (file)
@@ -766,9 +766,9 @@ search_start (struct GNUNET_FS_Handle *h,
                  _("Too many keywords specified for a single search."));
       return NULL;
     }
-  client = GNUNET_CLIENT_connect (sc->h->sched,
+  client = GNUNET_CLIENT_connect (h->sched,
                                  "fs",
-                                 sc->h->cfg);
+                                 h->cfg);
   if (NULL == client)
     return NULL;
   sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext));
index 03dae383f9cc65164890e9ae18211afcb092c9c8..977344b98d8ab5ceedda9f1053d77ee279b4f8f5 100644 (file)
@@ -223,8 +223,8 @@ unindex_process (void *cls,
     }
   GNUNET_DATASTORE_remove (uc->dsh,
                           query,
-                          block_size,
-                          block,
+                          size,
+                          data,
                           &process_cont,
                           uc,
                           GNUNET_CONSTANTS_SERVICE_TIMEOUT);
index 61fb7d61df382afdd0686dc2fdeebceeaaa59323..4f4a82c2c745ba4637ac9702c2e422ae9674cbed 100644 (file)
@@ -492,7 +492,6 @@ enc2bin (const char *input, void *data, size_t size)
   bits = 0;
   hbits = 0;
   len = 0;
-  pos = 0;
   for (pos = 0; pos < size; pos++)
     {
       while (hbits < 8)
index 3a6030fdac710f487df656632d4b3a3eb01301ab..281779897d3c306e9dcb5c6468fc4735133db077 100644 (file)
@@ -206,11 +206,24 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
     {
       size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
       hello = (const struct GNUNET_HELLO_Message *) buffer;
-      now = GNUNET_TIME_absolute_get ();
-      hello_clean = GNUNET_HELLO_iterate_addresses (hello,
-                                                    GNUNET_YES,
-                                                    &discard_expired, &now);
-      entry->hello = hello_clean;
+      if ( (size < sizeof (struct GNUNET_MessageHeader)) ||
+          (size != ntohs((((const struct GNUNET_MessageHeader*) hello)->size))) ||
+          (size != GNUNET_HELLO_size (hello)) )
+       {
+         GNUNET_break (0);
+         if (0 != UNLINK (fn))
+           GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                     "unlink",
+                                     fn);
+       }
+      else
+       {
+         now = GNUNET_TIME_absolute_get ();
+         hello_clean = GNUNET_HELLO_iterate_addresses (hello,
+                                                       GNUNET_YES,
+                                                       &discard_expired, &now);
+         entry->hello = hello_clean;
+       }
     }
   GNUNET_free (fn);
   entry->next = hosts;
index 28865edc6d52a1b5f1e6b429eb65090865e88ce3..57197798bc402b8cbe0841ceba0c238c7f7159b3 100644 (file)
@@ -262,8 +262,8 @@ GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
   struct GNUNET_CLIENT_Connection *client;
   struct ListAllPeersMessage *lapm;
   struct ListPeerMessage *lpm;
-  size_t hs;
   struct InfoContext *ihc;
+  size_t hs;
 
   client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
   if (client == NULL)
@@ -279,7 +279,6 @@ GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
   ihc->callback = callback;
   ihc->callback_cls = callback_cls;
   ihc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
-  hs = 0;
   if (peer == NULL)
     {
       lapm = (struct ListAllPeersMessage *) &ihc[1];
index 3e696827f20c247338acfec2288fee427a8d35ca..09f87d44457ddc64e0d01caee84946a1cbb5aec5 100644 (file)
@@ -2178,7 +2178,8 @@ plugin_env_receive (void *cls,
         }
       GNUNET_free (im);
     }
-  GNUNET_assert (NULL != service_context->neighbour);
+  GNUNET_assert ( (service_context == NULL) ||
+                 (NULL != service_context->neighbour) );
   return service_context;
 }
 
index 17570254bd974b10cd2f94a86e11cf82363a1464..bfa17d275079c60a5ad14761266b27926d548662 100644 (file)
@@ -1340,7 +1340,6 @@ update_quota (struct Session *session, int force)
   else
     {
       /* got more than acceptable */
-      total_remaining = 0;
       session->last_received -= total_allowed;
       delta = 0;
     }
index 0ce672dd9bb16ba8397e683be7d7d764c194656f..8c32618e2f033f1345049e49dc2cd9170b47f4fc 100644 (file)
@@ -807,13 +807,11 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
   char *end;
   char *match;
   char old;
-  int ret;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
     return GNUNET_NO;
   match = escape_name (value);
-  ret = 0;
   pos = list;
   while (1)
     {
index 45e599bcf7b67082378488d45d9dc18338f05042..bc15113c64037481fa9fd0aca08f06394e03b2a7 100644 (file)
@@ -214,10 +214,6 @@ sha512_transform (unsigned long long *state, const unsigned char *input)
   state[5] += f;
   state[6] += g;
   state[7] += h;
-
-  /* erase our data */
-  a = b = c = d = e = f = g = h = t1 = t2 = 0;
-  memset (W, 0, 80 * sizeof (unsigned long long));
 }
 
 static void
@@ -281,13 +277,13 @@ sha512_final (struct sha512_ctx *sctx, unsigned char *hash)
   static unsigned char padding[128] = { 0x80, };
 
   unsigned int t;
-  unsigned long long t2;
   unsigned char bits[128];
-  unsigned int index, pad_len;
+  unsigned int index;
+  unsigned int pad_len;
+  unsigned long long t2;
   int i, j;
 
-  index = pad_len = t = i = j = 0;
-  t2 = 0;
+  t = i = j = 0;
 
   /* Save number of bits */
   t = sctx->count[0];
index f686c0359218f4bc39b326f66576e613dd67e1b9..edf1b2bdf1b306d53f38510ae43650d0ac21ed70 100644 (file)
@@ -602,7 +602,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                           _
                           ("Could not aquire lock on file `%s' due to process %u: %s...\n"),
-                          filename, fl.l_pid, STRERROR (errno));
+                          filename, fl.l_pid, STRERROR (ec));
             }
           memset (&fl, 0, sizeof (struct flock));
           fl.l_type = F_WRLCK;
@@ -624,7 +624,6 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
       fl.l_type = F_UNLCK;
       fl.l_whence = SEEK_SET;
       fl.l_len = sizeof (struct RsaPrivateKeyBinaryEncoded);
-      cnt = 0;
       if (0 != fcntl (fd, F_SETLK, &fl))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                                   "fcntl", filename);
@@ -659,7 +658,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                           _
                           ("Could not aquire lock on file `%s' due to process %u: %s...\n"),
-                          filename, fl.l_pid, STRERROR (errno));
+                          filename, fl.l_pid, STRERROR (ec));
               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                           _
                           ("This may be ok if someone is currently generating a hostkey.\n"));
index 3f46923f700c634b4bf376876001ab33d132c97c..f6a4e7b9046fff9e01da8bb389b925c2b85f0fc9 100644 (file)
@@ -1038,7 +1038,6 @@ GNUNET_DISK_file_open (const char *fn, int flags, ...)
 
 #ifndef MINGW
   mode = 0;
-  oflags = 0;
   if (GNUNET_DISK_OPEN_READWRITE == (flags & GNUNET_DISK_OPEN_READWRITE))
     oflags = O_RDWR; /* note: O_RDWR is NOT always O_RDONLY | O_WRONLY */
   else if (flags & GNUNET_DISK_OPEN_READ)
index 3aea5d102af6455524c5cdab70e988a2b4c6cfc5..a8a800a006fa545fd02a8ece059bc790871c87dc 100644 (file)
@@ -50,11 +50,11 @@ GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext
                             const char *value)
 {
   const char *about = scls;
-  int slen;
-  int i;
+  size_t slen;
+  unsigned int i;
   int j;
-  int ml;
-  int p;
+  size_t ml;
+  size_t p;
   char *scp;
   const char *trans;
   const struct GNUNET_GETOPT_CommandLineOption *opt;
@@ -62,7 +62,6 @@ GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext
   printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
   printf (_
           ("Arguments mandatory for long options are also mandatory for short options.\n"));
-  slen = 0;
   i = 0;
   opt = ctx->allOptions;
   while (opt[i].description != NULL)
index cc1d61c2099c2e724eb8407fe7812ad1c37088a2..39b5174e360394c61f415c7036989d848b59585f 100644 (file)
@@ -213,14 +213,12 @@ get_path_from_PATH ()
   char *end;
   char *buf;
   const char *p;
-  size_t size;
 
   p = getenv ("PATH");
   if (p == NULL)
     return NULL;
   path = GNUNET_strdup (p);     /* because we write on it */
   buf = GNUNET_malloc (strlen (path) + 20);
-  size = strlen (path);
   pos = path;
 
   while (NULL != (end = strchr (pos, ':')))
index 4268772df5fd605324f91950419639c2aa112423..c872350c5fc40ba45a589c332c83ef5b3cbfdffe 100644 (file)
@@ -163,13 +163,11 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
 #elif HAVE_GETIFADDRS && HAVE_FREEIFADDRS
 
   struct ifaddrs *ifa_first;
+  struct ifaddrs *ifa_ptr;
   socklen_t alen;
 
   if (getifaddrs (&ifa_first) == 0)
     {
-      struct ifaddrs *ifa_ptr;
-
-      ifa_ptr = ifa_first;
       for (ifa_ptr = ifa_first; ifa_ptr != NULL; ifa_ptr = ifa_ptr->ifa_next)
         {
           if (ifa_ptr->ifa_name != NULL &&
index 2ce553a21513b74083f3085e22db1ba9ad06d1d6..a694b64818e61815e756ddc73aece57ab82a67f4 100644 (file)
@@ -145,7 +145,6 @@ getWeakKeys ()
         {
           printf ("testweakkey: gcry_cipher_open failed on trial %d. %s\n",
                   number_of_runs, gcry_strerror (rc));
-          rc = 0;
           continue;
         }
 
index b46a3eb595e78f51a86a2c1b4772cc1fe8271dc0..7165e7ef285f59562c1522be6155c59e4d1ae4c5 100644 (file)
@@ -165,7 +165,7 @@ testdisk ()
     }
   fprintf (stderr, "\n");
   GNUNET_CONFIGURATION_destroy (cfg);
-  return 0;
+  return ret;
 }
 
 int
index 0d5af1c0c4eb364784caebedf44ad85c656313a1..8113899535b59fcd5be864e1e1394ce1cb28a3ca 100644 (file)
@@ -138,7 +138,6 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   int *ok = cls;
   GNUNET_SCHEDULER_TaskIdentifier t2;
-  GNUNET_SCHEDULER_TaskIdentifier t3;
   GNUNET_SCHEDULER_TaskIdentifier t4;
 
   GNUNET_assert (1 == *ok);
@@ -154,12 +153,12 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                    GNUNET_NO,
                                    GNUNET_SCHEDULER_PRIORITY_IDLE,
                                    t2, &task4, cls);
-  t3 = GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                     GNUNET_NO,
-                                     GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                     t2,
-                                     GNUNET_TIME_relative_get_zero (),
-                                     &task3, cls);
+  GNUNET_SCHEDULER_add_delayed (tc->sched,
+                               GNUNET_NO,
+                               GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+                               t2,
+                               GNUNET_TIME_relative_get_zero (),
+                               &task3, cls);
   /* t4 will go first: lower prio, but prereq! */
   GNUNET_SCHEDULER_add_after (tc->sched,
                               GNUNET_NO,