diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-05-02 13:24:13 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-05-02 13:24:13 +0000 |
commit | 4ba7a736fee18101f5a3d232353a206b3a298b66 (patch) | |
tree | 00c06e1fcf237c928cd049846de2bcb2c7e14a32 /src/peerinfo-tool | |
parent | 434a4c8c7d5d2d89624f8dbd9a101c6c61e4febd (diff) | |
download | gnunet-4ba7a736fee18101f5a3d232353a206b3a298b66.tar.gz gnunet-4ba7a736fee18101f5a3d232353a206b3a298b66.zip |
fix 2297
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index d5a19e9c2..2c26c4599 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -501,6 +501,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
501 | struct GNUNET_PEERINFO_HelloAddressParsingContext *ctx = cls; | 501 | struct GNUNET_PEERINFO_HelloAddressParsingContext *ctx = cls; |
502 | const char *tname; | 502 | const char *tname; |
503 | const char *address; | 503 | const char *address; |
504 | char * address_terminated; | ||
504 | const char *end; | 505 | const char *end; |
505 | char *plugin_name; | 506 | char *plugin_name; |
506 | struct tm expiration_time; | 507 | struct tm expiration_time; |
@@ -528,12 +529,16 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
528 | if (NULL == tname) | 529 | if (NULL == tname) |
529 | { | 530 | { |
530 | ctx->ret = GNUNET_SYSERR; | 531 | ctx->ret = GNUNET_SYSERR; |
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | _("Failed to parse HELLO message: missing expiration time\n")); | ||
531 | GNUNET_break (0); | 534 | GNUNET_break (0); |
532 | return 0; | 535 | return 0; |
533 | } | 536 | } |
534 | expiration_seconds = mktime (&expiration_time); | 537 | expiration_seconds = mktime (&expiration_time); |
535 | if (expiration_seconds == (time_t) -1) | 538 | if (expiration_seconds == (time_t) -1) |
536 | { | 539 | { |
540 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
541 | _("Failed to parse HELLO message: invalid expiration time\n")); | ||
537 | ctx->ret = GNUNET_SYSERR; | 542 | ctx->ret = GNUNET_SYSERR; |
538 | GNUNET_break (0); | 543 | GNUNET_break (0); |
539 | return 0; | 544 | return 0; |
@@ -541,6 +546,8 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
541 | expire.abs_value = expiration_seconds * 1000; | 546 | expire.abs_value = expiration_seconds * 1000; |
542 | if ('!' != tname[0]) | 547 | if ('!' != tname[0]) |
543 | { | 548 | { |
549 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
550 | _("Failed to parse HELLO message: malformed\n")); | ||
544 | ctx->ret = GNUNET_SYSERR; | 551 | ctx->ret = GNUNET_SYSERR; |
545 | GNUNET_break (0); | 552 | GNUNET_break (0); |
546 | return 0; | 553 | return 0; |
@@ -549,6 +556,8 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
549 | address = strchr (tname, (int) '!'); | 556 | address = strchr (tname, (int) '!'); |
550 | if (NULL == address) | 557 | if (NULL == address) |
551 | { | 558 | { |
559 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
560 | _("Failed to parse HELLO message: missing transport plugin\n")); | ||
552 | ctx->ret = GNUNET_SYSERR; | 561 | ctx->ret = GNUNET_SYSERR; |
553 | GNUNET_break (0); | 562 | GNUNET_break (0); |
554 | return 0; | 563 | return 0; |
@@ -557,12 +566,20 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
557 | end = strchr (address, (int) '!'); | 566 | end = strchr (address, (int) '!'); |
558 | if (NULL == end) | 567 | if (NULL == end) |
559 | { | 568 | { |
560 | ctx->pos = NULL; | 569 | /* Last address */ |
561 | end = address + strlen (address); | 570 | end = address + strlen (address); |
571 | address_terminated = strdup (address); | ||
572 | ctx->pos = NULL; | ||
562 | } | 573 | } |
563 | else | 574 | else |
564 | { | 575 | { |
576 | /* More addresses follow */ | ||
577 | size_t len = (end - address); | ||
578 | address_terminated = GNUNET_malloc (len + 1); | ||
579 | memcpy (address_terminated, address, len); | ||
580 | address_terminated[len] = '\0'; | ||
565 | ctx->pos = end; | 581 | ctx->pos = end; |
582 | |||
566 | } | 583 | } |
567 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); | 584 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); |
568 | papi = GPI_plugins_find (plugin_name); | 585 | papi = GPI_plugins_find (plugin_name); |
@@ -578,6 +595,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
578 | GNUNET_free (plugin_name); | 595 | GNUNET_free (plugin_name); |
579 | 596 | ||
580 | GNUNET_break (0); | 597 | GNUNET_break (0); |
598 | GNUNET_free (address_terminated); | ||
581 | return 0; | 599 | return 0; |
582 | } | 600 | } |
583 | if (NULL == papi->string_to_address) | 601 | if (NULL == papi->string_to_address) |
@@ -586,17 +604,23 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
586 | _("Plugin `%s' does not support URIs yet\n"), | 604 | _("Plugin `%s' does not support URIs yet\n"), |
587 | plugin_name); | 605 | plugin_name); |
588 | GNUNET_free (plugin_name); | 606 | GNUNET_free (plugin_name); |
607 | GNUNET_free (address_terminated); | ||
589 | GNUNET_break (0); | 608 | GNUNET_break (0); |
590 | return 0; | 609 | return 0; |
591 | } | 610 | } |
611 | |||
592 | if (GNUNET_OK != | 612 | if (GNUNET_OK != |
593 | papi->string_to_address (papi->cls, | 613 | papi->string_to_address (papi->cls, |
594 | address, | 614 | address_terminated, |
595 | end - address, | 615 | strlen (address_terminated) + 1, |
596 | &addr, | 616 | &addr, |
597 | &addr_len)) | 617 | &addr_len)) |
598 | { | 618 | { |
619 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
620 | _("Failed to parse `%s'\n"), | ||
621 | address_terminated); | ||
599 | GNUNET_free (plugin_name); | 622 | GNUNET_free (plugin_name); |
623 | GNUNET_free (address_terminated); | ||
600 | return 0; | 624 | return 0; |
601 | } | 625 | } |
602 | /* address.peer is unset - not used by add_address() */ | 626 | /* address.peer is unset - not used by add_address() */ |
@@ -606,6 +630,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
606 | ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max); | 630 | ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max); |
607 | GNUNET_free (addr); | 631 | GNUNET_free (addr); |
608 | GNUNET_free (plugin_name); | 632 | GNUNET_free (plugin_name); |
633 | GNUNET_free (address_terminated); | ||
609 | return ret; | 634 | return ret; |
610 | } | 635 | } |
611 | 636 | ||