diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-10-12 09:51:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-10-12 09:51:26 +0000 |
commit | 74095663e052f01d591aad4cdb2338d4d8f6fde9 (patch) | |
tree | f43e28c622ff34fba1496bb35282b3a57e2a22d9 /src/transport | |
parent | 254bfc79fca2ed3f50ffbe4d5759a1f99922a154 (diff) | |
download | gnunet-74095663e052f01d591aad4cdb2338d4d8f6fde9.tar.gz gnunet-74095663e052f01d591aad4cdb2338d4d8f6fde9.zip |
fixing issue pointed out by amatus
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 21 | ||||
-rw-r--r-- | 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, | |||
3308 | { | 3308 | { |
3309 | ping.header.size = htons(sizeof(struct TransportPingMessage)); | 3309 | ping.header.size = htons(sizeof(struct TransportPingMessage)); |
3310 | } | 3310 | } |
3311 | |||
3311 | memcpy(&message_buf[hello_size], | 3312 | memcpy(&message_buf[hello_size], |
3312 | &ping, | 3313 | &ping, |
3313 | sizeof(struct TransportPingMessage)); | 3314 | sizeof(struct TransportPingMessage)); |
@@ -3335,8 +3336,6 @@ send_periodic_ping (void *cls, | |||
3335 | gettext_noop ("# PING without HELLO messages sent"), | 3336 | gettext_noop ("# PING without HELLO messages sent"), |
3336 | 1, | 3337 | 1, |
3337 | GNUNET_NO); | 3338 | GNUNET_NO); |
3338 | |||
3339 | |||
3340 | GNUNET_STATISTICS_update (stats, | 3339 | GNUNET_STATISTICS_update (stats, |
3341 | gettext_noop ("# PING messages sent for re-validation"), | 3340 | gettext_noop ("# PING messages sent for re-validation"), |
3342 | 1, | 3341 | 1, |
@@ -3515,7 +3514,7 @@ check_pending_validation (void *cls, | |||
3515 | } | 3514 | } |
3516 | addr = (const char*) &pong[1]; | 3515 | addr = (const char*) &pong[1]; |
3517 | slen = strlen (ve->transport_name) + 1; | 3516 | slen = strlen (ve->transport_name) + 1; |
3518 | if ( (ps - sizeof (struct TransportPongMessage) != ve->addrlen + slen) || | 3517 | if ( (ps - sizeof (struct TransportPongMessage) < slen) || |
3519 | (ve->challenge != challenge) || | 3518 | (ve->challenge != challenge) || |
3520 | (addr[slen-1] != '\0') || | 3519 | (addr[slen-1] != '\0') || |
3521 | (0 != strcmp (addr, ve->transport_name)) || | 3520 | (0 != strcmp (addr, ve->transport_name)) || |
@@ -3523,7 +3522,7 @@ check_pending_validation (void *cls, | |||
3523 | != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 3522 | != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
3524 | sizeof (uint32_t) + | 3523 | sizeof (uint32_t) + |
3525 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | 3524 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
3526 | sizeof (struct GNUNET_PeerIdentity) + ve->addrlen + slen) ) | 3525 | sizeof (struct GNUNET_PeerIdentity) + ps - sizeof (struct TransportPongMessage)) ) |
3527 | { | 3526 | { |
3528 | return GNUNET_YES; | 3527 | return GNUNET_YES; |
3529 | } | 3528 | } |
@@ -3567,18 +3566,18 @@ check_pending_validation (void *cls, | |||
3567 | #endif | 3566 | #endif |
3568 | break; | 3567 | break; |
3569 | case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: | 3568 | case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: |
3570 | if (ve->addrlen != 0) | 3569 | if (0 != memcmp (&pong->pid, |
3571 | { | ||
3572 | return GNUNET_YES; /* different entry, keep trying */ | ||
3573 | } | ||
3574 | if ( (0 != memcmp (&pong->pid, | ||
3575 | &my_identity, | 3570 | &my_identity, |
3576 | sizeof (struct GNUNET_PeerIdentity))) || | 3571 | sizeof (struct GNUNET_PeerIdentity))) |
3577 | (ve->addrlen != 0) ) | ||
3578 | { | 3572 | { |
3579 | GNUNET_break_op (0); | 3573 | GNUNET_break_op (0); |
3580 | return GNUNET_NO; | 3574 | return GNUNET_NO; |
3581 | } | 3575 | } |
3576 | if (ve->addrlen != 0) | ||
3577 | { | ||
3578 | /* must have been for a different validation entry */ | ||
3579 | return GNUNET_YES; | ||
3580 | } | ||
3582 | tp = find_transport (ve->transport_name); | 3581 | tp = find_transport (ve->transport_name); |
3583 | if (tp == NULL) | 3582 | if (tp == NULL) |
3584 | { | 3583 | { |
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) | |||
2221 | return GNUNET_YES; | 2221 | return GNUNET_YES; |
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | |||
2224 | /** | 2225 | /** |
2225 | * Return the actual path to a file found in the current | 2226 | * Return the actual path to a file found in the current |
2226 | * PATH environment variable. | 2227 | * PATH environment variable. |
@@ -2238,11 +2239,11 @@ get_path_from_PATH (char *binary) | |||
2238 | 2239 | ||
2239 | p = getenv ("PATH"); | 2240 | p = getenv ("PATH"); |
2240 | if (p == NULL) | 2241 | if (p == NULL) |
2241 | { | 2242 | { |
2242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is NULL, returning.\n"); | 2243 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2243 | return NULL; | 2244 | _("PATH environment variable is unset.\n")); |
2244 | } | 2245 | return NULL; |
2245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is `%s', PATH_SEPARATOR is '%c'\n", p, PATH_SEPARATOR); | 2246 | } |
2246 | path = GNUNET_strdup (p); /* because we write on it */ | 2247 | path = GNUNET_strdup (p); /* because we write on it */ |
2247 | buf = GNUNET_malloc (strlen (path) + 20); | 2248 | buf = GNUNET_malloc (strlen (path) + 20); |
2248 | pos = path; | 2249 | pos = path; |
@@ -2253,21 +2254,17 @@ get_path_from_PATH (char *binary) | |||
2253 | sprintf (buf, "%s/%s", pos, binary); | 2254 | sprintf (buf, "%s/%s", pos, binary); |
2254 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | 2255 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) |
2255 | { | 2256 | { |
2256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf); | ||
2257 | GNUNET_free (path); | 2257 | GNUNET_free (path); |
2258 | return buf; | 2258 | return buf; |
2259 | } | 2259 | } |
2260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf); | ||
2261 | pos = end + 1; | 2260 | pos = end + 1; |
2262 | } | 2261 | } |
2263 | sprintf (buf, "%s/%s", pos, binary); | 2262 | sprintf (buf, "%s/%s", pos, binary); |
2264 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | 2263 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) |
2265 | { | 2264 | { |
2266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf); | ||
2267 | GNUNET_free (path); | 2265 | GNUNET_free (path); |
2268 | return buf; | 2266 | return buf; |
2269 | } | 2267 | } |
2270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf); | ||
2271 | GNUNET_free (buf); | 2268 | GNUNET_free (buf); |
2272 | GNUNET_free (path); | 2269 | GNUNET_free (path); |
2273 | return NULL; | 2270 | return NULL; |
@@ -2298,13 +2295,18 @@ check_gnunet_nat_binary(char *binary) | |||
2298 | p = get_path_from_PATH (binary); | 2295 | p = get_path_from_PATH (binary); |
2299 | #endif | 2296 | #endif |
2300 | if (p == NULL) | 2297 | if (p == NULL) |
2301 | { | 2298 | { |
2302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "get_path_from_PATH (%s) have failed!\n", binary); | 2299 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2303 | return GNUNET_NO; | 2300 | _("Could not find binary `%s' in PATH!\n"), |
2304 | } | 2301 | binary); |
2302 | return GNUNET_NO; | ||
2303 | } | ||
2305 | if (0 != STAT (p, &statbuf)) | 2304 | if (0 != STAT (p, &statbuf)) |
2306 | { | 2305 | { |
2307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STAT (%s, &statbuf) have failed!\n", p); | 2306 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2307 | _("stat (%s) failed: %s\n"), | ||
2308 | p, | ||
2309 | STRERROR (errno)); | ||
2308 | GNUNET_free (p); | 2310 | GNUNET_free (p); |
2309 | return GNUNET_SYSERR; | 2311 | return GNUNET_SYSERR; |
2310 | } | 2312 | } |
@@ -2317,11 +2319,12 @@ check_gnunet_nat_binary(char *binary) | |||
2317 | #else | 2319 | #else |
2318 | rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); | 2320 | rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); |
2319 | if (INVALID_SOCKET == rawsock) | 2321 | if (INVALID_SOCKET == rawsock) |
2320 | { | 2322 | { |
2321 | DWORD err = GetLastError (); | 2323 | DWORD err = GetLastError (); |
2322 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err); | 2324 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2323 | return GNUNET_NO; /* not running as administrator */ | 2325 | "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err); |
2324 | } | 2326 | return GNUNET_NO; /* not running as administrator */ |
2327 | } | ||
2325 | closesocket (rawsock); | 2328 | closesocket (rawsock); |
2326 | return GNUNET_YES; | 2329 | return GNUNET_YES; |
2327 | #endif | 2330 | #endif |