aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-10 17:38:52 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-10 17:38:52 +0100
commit287be62e649091b608c0d7bcf77c4c633a24b4e7 (patch)
tree6e147b815653a2371c5d6b24ec244ffe71549564 /src/nat
parent8939dc23ba994b2e077d06bd2c7a61c08919663f (diff)
downloadgnunet-287be62e649091b608c0d7bcf77c4c633a24b4e7.tar.gz
gnunet-287be62e649091b608c0d7bcf77c4c633a24b4e7.zip
fix memory leak
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/gnunet-nat.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index c785fe210..04bde5111 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -269,8 +269,10 @@ run (void *cls,
269 global_ret = 1; 269 global_ret = 1;
270 return; 270 return;
271 } 271 }
272 local_len = 0; /* make compilers happy */ 272 local_len = 0;
273 local_sa = NULL; 273 local_sa = NULL;
274 remote_len = 0;
275 remote_sa = NULL;
274 if (NULL != local_addr) 276 if (NULL != local_addr)
275 { 277 {
276 local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr, 278 local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr,
@@ -281,13 +283,10 @@ run (void *cls,
281 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 283 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
282 "Invalid socket address `%s'\n", 284 "Invalid socket address `%s'\n",
283 local_addr); 285 local_addr);
284 global_ret = 1; 286 goto fail_and_shutdown;
285 return;
286 } 287 }
287 } 288 }
288 289
289 remote_len = 0;
290
291 if (NULL != remote_addr) 290 if (NULL != remote_addr)
292 { 291 {
293 remote_len = GNUNET_STRINGS_parse_socket_addr (remote_addr, 292 remote_len = GNUNET_STRINGS_parse_socket_addr (remote_addr,
@@ -298,8 +297,7 @@ run (void *cls,
298 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 297 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
299 "Invalid socket address `%s'\n", 298 "Invalid socket address `%s'\n",
300 remote_addr); 299 remote_addr);
301 global_ret = 1; 300 goto fail_and_shutdown;
302 return;
303 } 301 }
304 } 302 }
305 303
@@ -321,9 +319,7 @@ run (void *cls,
321 { 319 {
322 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 320 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
323 "Use of `-W` only effective in combination with `-i`\n"); 321 "Use of `-W` only effective in combination with `-i`\n");
324 global_ret = 1; 322 goto fail_and_shutdown;
325 GNUNET_SCHEDULER_shutdown ();
326 return;
327 } 323 }
328 324
329 if (NULL != remote_addr) 325 if (NULL != remote_addr)
@@ -335,17 +331,13 @@ run (void *cls,
335 { 331 {
336 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 332 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
337 "Require IPv4 local address to initiate connection reversal\n"); 333 "Require IPv4 local address to initiate connection reversal\n");
338 global_ret = 1; 334 goto fail_and_shutdown;
339 GNUNET_SCHEDULER_shutdown ();
340 return;
341 } 335 }
342 if (sizeof (struct sockaddr_in) != remote_len) 336 if (sizeof (struct sockaddr_in) != remote_len)
343 { 337 {
344 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 338 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
345 "Require IPv4 reversal target address\n"); 339 "Require IPv4 reversal target address\n");
346 global_ret = 1; 340 goto fail_and_shutdown;
347 GNUNET_SCHEDULER_shutdown ();
348 return;
349 } 341 }
350 GNUNET_assert (AF_INET == local_sa->sa_family); 342 GNUNET_assert (AF_INET == local_sa->sa_family);
351 GNUNET_assert (AF_INET == remote_sa->sa_family); 343 GNUNET_assert (AF_INET == remote_sa->sa_family);
@@ -374,17 +366,13 @@ run (void *cls,
374 { 366 {
375 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 367 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
376 "Require local address to support STUN requests\n"); 368 "Require local address to support STUN requests\n");
377 global_ret = 1; 369 goto fail_and_shutdown;
378 GNUNET_SCHEDULER_shutdown ();
379 return;
380 } 370 }
381 if (IPPROTO_UDP != proto) 371 if (IPPROTO_UDP != proto)
382 { 372 {
383 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 373 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
384 "STUN only supported over UDP\n"); 374 "STUN only supported over UDP\n");
385 global_ret = 1; 375 goto fail_and_shutdown;
386 GNUNET_SCHEDULER_shutdown ();
387 return;
388 } 376 }
389 ls = GNUNET_NETWORK_socket_create (af, 377 ls = GNUNET_NETWORK_socket_create (af,
390 SOCK_DGRAM, 378 SOCK_DGRAM,
@@ -399,17 +387,22 @@ run (void *cls,
399 GNUNET_a2s (local_sa, 387 GNUNET_a2s (local_sa,
400 local_len), 388 local_len),
401 STRERROR (errno)); 389 STRERROR (errno));
402 global_ret = 1; 390 goto fail_and_shutdown;
403 GNUNET_SCHEDULER_shutdown ();
404 return;
405 } 391 }
406 rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 392 rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
407 ls, 393 ls,
408 &stun_read_task, 394 &stun_read_task,
409 NULL); 395 NULL);
410 } 396 }
411 397 GNUNET_free_non_null (remote_sa);
398 GNUNET_free_non_null (local_sa);
412 test_finished (); 399 test_finished ();
400 return;
401 fail_and_shutdown:
402 global_ret = 1;
403 GNUNET_SCHEDULER_shutdown ();
404 GNUNET_free_non_null (remote_sa);
405 GNUNET_free_non_null (local_sa);
413} 406}
414 407
415 408