From 74095663e052f01d591aad4cdb2338d4d8f6fde9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 12 Oct 2010 09:51:26 +0000 Subject: [PATCH] fixing issue pointed out by amatus --- src/transport/gnunet-service-transport.c | 21 ++++++------ src/transport/plugin_transport_tcp.c | 41 +++++++++++++----------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index a4499f650..9d3e9d7c5 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -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) { diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 2b4553930..bf14092fb 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -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 -- 2.25.1