trying again to fix test_service timeout on v6 failure
authorChristian Grothoff <christian@grothoff.org>
Thu, 4 Jan 2018 16:05:05 +0000 (17:05 +0100)
committerChristian Grothoff <christian@grothoff.org>
Thu, 4 Jan 2018 16:05:05 +0000 (17:05 +0100)
src/util/crypto_ecc.c
src/util/crypto_ecc_dlog.c
src/util/crypto_ecc_setup.c
src/util/crypto_hash_file.c
src/util/test_service.c

index 7845932ee725ca680d0e825824d3edcd315a151a..5d5e8a9cec5b2d1c2717f5c0d7ac9d151524d85f 100644 (file)
@@ -1242,7 +1242,7 @@ eddsa_d_to_a (gcry_mpi_t d)
   size_t rawmpilen;
   unsigned char digest[64]; /* 512-bit hash value */
   gcry_buffer_t hvec[2];
-  int b;
+  unsigned int b;
   gcry_mpi_t a;
 
   b = 256 / 8; /* number of bytes in `d` */
@@ -1257,7 +1257,7 @@ eddsa_d_to_a (gcry_mpi_t d)
                                  d));
   hvec[0].data = digest;
   hvec[0].off = 0;
-  hvec[0].len = b > rawmpilen? b - rawmpilen : 0;
+  hvec[0].len = b > rawmpilen ? (b - rawmpilen) : 0;
   hvec[1].data = rawmpi;
   hvec[1].off = 0;
   hvec[1].len = rawmpilen;
index 38e2088cc07780e5c436647fae7400e046f5d304..91411368f67ec75fd18147b5655d1d1ef788b103 100644 (file)
@@ -130,6 +130,7 @@ GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc,
   gcry_ctx_t ctx;
   gcry_mpi_point_t q;
 
+  (void) edc;
   if (0 != gcry_sexp_build (&pub_sexpr, NULL,
                             "(public-key(ecc(curve " CURVE ")(q %b)))",
                             (int) sizeof (bin->q_y),
index 64610ddd3430ad74dfd70d5cfae18a85b10bd77d..e7caf9ded3a5348f940ac7f6510a2399c21096aa 100644 (file)
@@ -80,6 +80,7 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
   unsigned int cnt;
   int ec;
   uint64_t fs;
+  ssize_t sret;
 
   if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
@@ -193,7 +194,8 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
              _("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
-             filename, (unsigned int) fs,
+             filename,
+            (unsigned int) fs,
              (unsigned int) sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
         LOG (GNUNET_ERROR_TYPE_ERROR,
              _("This may be ok if someone is currently generating a key.\n"));
@@ -205,12 +207,20 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
   }
   fs = sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs));
+  sret = GNUNET_DISK_file_read (fd,
+                               priv,
+                               fs);
+  GNUNET_assert ( (sret >= 0) &&
+                 (fs == (size_t) sret) );
   if (GNUNET_YES !=
-      GNUNET_DISK_file_unlock (fd, 0,
+      GNUNET_DISK_file_unlock (fd,
+                              0,
                                sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                      "fcntl",
+                      filename);
+  GNUNET_assert (GNUNET_YES ==
+                GNUNET_DISK_file_close (fd));
   return priv;
 }
 
@@ -237,8 +247,10 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
   unsigned int cnt;
   int ec;
   uint64_t fs;
-
-  if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
+  ssize_t sret;
+  
+  if (GNUNET_SYSERR ==
+      GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
   while (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
@@ -255,19 +267,24 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
         {
           /* must exist but not be accessible, fail for good! */
           if (0 != ACCESS (filename, R_OK))
-            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename);
+            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                              "access",
+                              filename);
           else
             GNUNET_break (0);   /* what is going on!? */
           return NULL;
         }
         continue;
       }
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                        "open",
+                        filename);
       return NULL;
     }
     cnt = 0;
     while (GNUNET_YES !=
-           GNUNET_DISK_file_lock (fd, 0,
+           GNUNET_DISK_file_lock (fd,
+                                 0,
                                   sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
                                   GNUNET_YES))
     {
@@ -276,7 +293,8 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"), filename,
+             _("Could not acquire lock on file `%s': %s...\n"),
+            filename,
              STRERROR (ec));
       }
     }
@@ -285,21 +303,29 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
     priv = GNUNET_CRYPTO_ecdsa_key_create ();
     GNUNET_assert (NULL != priv);
     GNUNET_assert (sizeof (*priv) ==
-                   GNUNET_DISK_file_write (fd, priv, sizeof (*priv)));
+                   GNUNET_DISK_file_write (fd,
+                                          priv,
+                                          sizeof (*priv)));
     GNUNET_DISK_file_sync (fd);
     if (GNUNET_YES !=
         GNUNET_DISK_file_unlock (fd, 0,
                                  sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-    GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                        "fcntl",
+                        filename);
+    GNUNET_assert (GNUNET_YES ==
+                  GNUNET_DISK_file_close (fd));
     return priv;
   }
   /* key file exists already, read it! */
-  fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+  fd = GNUNET_DISK_file_open (filename,
+                             GNUNET_DISK_OPEN_READ,
                               GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                      "open",
+                      filename);
     return NULL;
   }
   cnt = 0;
@@ -318,25 +344,34 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
             filename,
              STRERROR (ec));
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _
-             ("This may be ok if someone is currently generating a private key.\n"));
+             _("This may be ok if someone is currently generating a private key.\n"));
       }
       short_wait ();
       continue;
     }
-    if (GNUNET_YES != GNUNET_DISK_file_test (filename))
+    if (GNUNET_YES !=
+       GNUNET_DISK_file_test (filename))
     {
       /* eh, what!? File we opened is now gone!? */
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                        "stat",
+                        filename);
       if (GNUNET_YES !=
           GNUNET_DISK_file_unlock (fd, 0,
                                    sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-      GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                          "fcntl",
+                          filename);
+      GNUNET_assert (GNUNET_OK ==
+                    GNUNET_DISK_file_close (fd));
 
       return NULL;
     }
-    if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
+    if (GNUNET_OK !=
+       GNUNET_DISK_file_size (filename,
+                              &fs,
+                              GNUNET_YES,
+                              GNUNET_YES))
       fs = 0;
     if (fs < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))
     {
@@ -345,7 +380,9 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
       if (GNUNET_YES !=
           GNUNET_DISK_file_unlock (fd, 0,
                                    sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                          "fcntl",
+                          filename);
       if (0 == ++cnt % 10)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -362,12 +399,19 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
   }
   fs = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs));
+  sret = GNUNET_DISK_file_read (fd,
+                               priv,
+                               fs);
+  GNUNET_assert ( (sret >= 0) &&
+                 (fs == (size_t) sret) );
   if (GNUNET_YES !=
       GNUNET_DISK_file_unlock (fd, 0,
                                sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                      "fcntl",
+                      filename);
+  GNUNET_assert (GNUNET_YES ==
+                GNUNET_DISK_file_close (fd));
   return priv;
 }
 
index 3e59002003a18949c880f71fa08935c18bdd3c19..cb632d02c5e155e967daa15895acd8ac6ce9e3f1 100644 (file)
@@ -124,23 +124,29 @@ file_hash_task (void *cls)
   struct GNUNET_CRYPTO_FileHashContext *fhc = cls;
   struct GNUNET_HashCode *res;
   size_t delta;
+  ssize_t sret;
 
   fhc->task = NULL;
   GNUNET_assert (fhc->offset <= fhc->fsize);
   delta = fhc->bsize;
   if (fhc->fsize - fhc->offset < delta)
     delta = fhc->fsize - fhc->offset;
-  if (delta != GNUNET_DISK_file_read (fhc->fh,
-                                     fhc->buffer,
-                                     delta))
+  sret = GNUNET_DISK_file_read (fhc->fh,
+                               fhc->buffer,
+                               delta);
+  if ( (sret < 0) ||
+       (delta != (size_t) sret) )
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
                       "read",
                       fhc->filename);
-    file_hash_finish (fhc, NULL);
+    file_hash_finish (fhc,
+                     NULL);
     return;
   }
-  gcry_md_write (fhc->md, fhc->buffer, delta);
+  gcry_md_write (fhc->md,
+                fhc->buffer,
+                delta);
   fhc->offset += delta;
   if (fhc->offset == fhc->fsize)
   {
index 3ffacb0a9930415d61c5a7ff6a9b3a2b37d7cb95..424a445bb5d5cb954b9d35ef006b1ebd7673d395 100644 (file)
@@ -52,8 +52,11 @@ handle_recv (void *cls,
              "Received client message...\n");
   GNUNET_SERVICE_client_continue (client);
   global_ret = 2;
-  GNUNET_MQ_destroy (mq);
-  mq = NULL;
+  if (NULL != mq)
+  {
+    GNUNET_MQ_destroy (mq);
+    mq = NULL;
+  }
 }
 
 
@@ -106,6 +109,11 @@ static void
 timeout_task (void *cls)
 {
   tt = NULL;
+  if (NULL != mq)
+  {
+    GNUNET_MQ_destroy (mq);
+    mq = NULL;
+  }
   global_ret = 33;
   GNUNET_SCHEDULER_shutdown ();
 }