fixing issue pointed out by amatus
authorChristian Grothoff <christian@grothoff.org>
Tue, 12 Oct 2010 09:51:26 +0000 (09:51 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 12 Oct 2010 09:51:26 +0000 (09:51 +0000)
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c

index a4499f65010093215df693d9d9fa7f7678c7911a..9d3e9d7c5d0c87dbb28a1f32b73e65d1bbba3d78 100644 (file)
@@ -3308,6 +3308,7 @@ send_periodic_ping (void *cls,
     {
       ping.header.size = htons(sizeof(struct TransportPingMessage));
     }
+
   memcpy(&message_buf[hello_size],
          &ping,
          sizeof(struct TransportPingMessage));
@@ -3335,8 +3336,6 @@ send_periodic_ping (void *cls,
                               gettext_noop ("# PING without HELLO messages sent"),
                               1,
                               GNUNET_NO);
-
-
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# PING messages sent for re-validation"),
                            1,
@@ -3515,7 +3514,7 @@ check_pending_validation (void *cls,
     }
   addr = (const char*) &pong[1];
   slen = strlen (ve->transport_name) + 1;
-  if ( (ps - sizeof (struct TransportPongMessage) != ve->addrlen + slen) ||
+  if ( (ps - sizeof (struct TransportPongMessage) < slen) ||
        (ve->challenge != challenge) ||
        (addr[slen-1] != '\0') ||
        (0 != strcmp (addr, ve->transport_name)) ||
@@ -3523,7 +3522,7 @@ check_pending_validation (void *cls,
        != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
        sizeof (uint32_t) +
        sizeof (struct GNUNET_TIME_AbsoluteNBO) +
-       sizeof (struct GNUNET_PeerIdentity) + ve->addrlen + slen) )
+       sizeof (struct GNUNET_PeerIdentity) + ps - sizeof (struct TransportPongMessage)) )
     {
       return GNUNET_YES;
     }
@@ -3567,18 +3566,18 @@ check_pending_validation (void *cls,
 #endif
       break;
     case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING:
-      if (ve->addrlen != 0)
-        {
-          return GNUNET_YES; /* different entry, keep trying */
-        }
-      if ( (0 != memcmp (&pong->pid,
+      if (0 != memcmp (&pong->pid,
                         &my_identity,
-                        sizeof (struct GNUNET_PeerIdentity))) ||
-          (ve->addrlen != 0) )
+                        sizeof (struct GNUNET_PeerIdentity)))
        {
          GNUNET_break_op (0);
          return GNUNET_NO;
        }
+      if (ve->addrlen != 0)
+        {
+          /* must have been for a different validation entry */
+          return GNUNET_YES;
+        }
       tp = find_transport (ve->transport_name);
       if (tp == NULL)
        {
index 2b4553930592585d7fda3921c9f09577b2029978..bf14092fb1037667c912b840033ca7e826882408 100644 (file)
@@ -2221,6 +2221,7 @@ tcp_transport_start_nat_server(struct Plugin *plugin)
   return GNUNET_YES;
 }
 
+
 /**
  * Return the actual path to a file found in the current
  * PATH environment variable.
@@ -2238,11 +2239,11 @@ get_path_from_PATH (char *binary)
 
   p = getenv ("PATH");
   if (p == NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is NULL, returning.\n");
-    return NULL;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is `%s', PATH_SEPARATOR is '%c'\n", p, PATH_SEPARATOR);
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("PATH environment variable is unset.\n"));
+      return NULL;
+    }
   path = GNUNET_strdup (p);     /* because we write on it */
   buf = GNUNET_malloc (strlen (path) + 20);
   pos = path;
@@ -2253,21 +2254,17 @@ get_path_from_PATH (char *binary)
       sprintf (buf, "%s/%s", pos, binary);
       if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf);
           GNUNET_free (path);
           return buf;
         }
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf);
       pos = end + 1;
     }
   sprintf (buf, "%s/%s", pos, binary);
   if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf);
       GNUNET_free (path);
       return buf;
     }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf);
   GNUNET_free (buf);
   GNUNET_free (path);
   return NULL;
@@ -2298,13 +2295,18 @@ check_gnunet_nat_binary(char *binary)
   p = get_path_from_PATH (binary);
 #endif
   if (p == NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "get_path_from_PATH (%s) have failed!\n", binary);
-    return GNUNET_NO;
-  }
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("Could not find binary `%s' in PATH!\n"),
+                 binary);
+      return GNUNET_NO;
+    }
   if (0 != STAT (p, &statbuf))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STAT (%s, &statbuf) have failed!\n", p);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 
+                 _("stat (%s) failed: %s\n"), 
+                 p,
+                 STRERROR (errno));
       GNUNET_free (p);
       return GNUNET_SYSERR;
     }
@@ -2317,11 +2319,12 @@ check_gnunet_nat_binary(char *binary)
 #else
   rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
   if (INVALID_SOCKET == rawsock)
-  {
-    DWORD err = GetLastError ();
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err);
-    return GNUNET_NO; /* not running as administrator */
-  }
+    {
+      DWORD err = GetLastError ();
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 
+                 "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err);
+      return GNUNET_NO; /* not running as administrator */
+    }
   closesocket (rawsock);
   return GNUNET_YES;
 #endif