aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-12 14:35:32 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-12 14:35:32 +0000
commit1a4273369f9c949b57b54460fb2269f413e22521 (patch)
tree1c6923901c3da6228b1e854ca17d46f73f6058be /src/peerinfo-tool
parent0f6e3bcd617ea997060756a9c4167806b137f440 (diff)
downloadgnunet-1a4273369f9c949b57b54460fb2269f413e22521.tar.gz
gnunet-1a4273369f9c949b57b54460fb2269f413e22521.zip
- off by one
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index ed4fd5193..d5a19e9c2 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -511,12 +511,12 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
511 size_t addr_len; 511 size_t addr_len;
512 struct GNUNET_HELLO_Address haddr; 512 struct GNUNET_HELLO_Address haddr;
513 size_t ret; 513 size_t ret;
514
515 if (NULL == ctx->pos) 514 if (NULL == ctx->pos)
516 return 0; 515 return 0;
517 if ('!' != ctx->pos[0]) 516 if ('!' != ctx->pos[0])
518 { 517 {
519 ctx->ret = GNUNET_SYSERR; 518 ctx->ret = GNUNET_SYSERR;
519 GNUNET_break (0);
520 return 0; 520 return 0;
521 } 521 }
522 ctx->pos++; 522 ctx->pos++;
@@ -524,21 +524,25 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
524 tname = strptime (ctx->pos, 524 tname = strptime (ctx->pos,
525 "%Y%m%d%H%M%S", 525 "%Y%m%d%H%M%S",
526 &expiration_time); 526 &expiration_time);
527
527 if (NULL == tname) 528 if (NULL == tname)
528 { 529 {
529 ctx->ret = GNUNET_SYSERR; 530 ctx->ret = GNUNET_SYSERR;
531 GNUNET_break (0);
530 return 0; 532 return 0;
531 } 533 }
532 expiration_seconds = mktime (&expiration_time); 534 expiration_seconds = mktime (&expiration_time);
533 if (expiration_seconds == (time_t) -1) 535 if (expiration_seconds == (time_t) -1)
534 { 536 {
535 ctx->ret = GNUNET_SYSERR; 537 ctx->ret = GNUNET_SYSERR;
538 GNUNET_break (0);
536 return 0; 539 return 0;
537 } 540 }
538 expire.abs_value = expiration_seconds * 1000; 541 expire.abs_value = expiration_seconds * 1000;
539 if ('!' != tname[0]) 542 if ('!' != tname[0])
540 { 543 {
541 ctx->ret = GNUNET_SYSERR; 544 ctx->ret = GNUNET_SYSERR;
545 GNUNET_break (0);
542 return 0; 546 return 0;
543 } 547 }
544 tname++; 548 tname++;
@@ -546,6 +550,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
546 if (NULL == address) 550 if (NULL == address)
547 { 551 {
548 ctx->ret = GNUNET_SYSERR; 552 ctx->ret = GNUNET_SYSERR;
553 GNUNET_break (0);
549 return 0; 554 return 0;
550 } 555 }
551 address++; 556 address++;
@@ -559,7 +564,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
559 { 564 {
560 ctx->pos = end; 565 ctx->pos = end;
561 } 566 }
562 plugin_name = GNUNET_strndup (tname, address - tname); 567 plugin_name = GNUNET_strndup (tname, address - (tname+1));
563 papi = GPI_plugins_find (plugin_name); 568 papi = GPI_plugins_find (plugin_name);
564 if (NULL == papi) 569 if (NULL == papi)
565 { 570 {
@@ -567,15 +572,21 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
567 * Skip this part, advance to the next one and recurse. 572 * Skip this part, advance to the next one and recurse.
568 * But only if this is not the end of string. 573 * But only if this is not the end of string.
569 */ 574 */
575 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
576 _("Plugin `%s' not found\n"),
577 plugin_name);
570 GNUNET_free (plugin_name); 578 GNUNET_free (plugin_name);
579
580 GNUNET_break (0);
571 return 0; 581 return 0;
572 } 582 }
573 if (NULL == papi->string_to_address) 583 if (NULL == papi->string_to_address)
574 { 584 {
575 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 585 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
576 _("Plugin `%s' does not support URIs yet\n"), 586 _("Plugin `%s' does not support URIs yet\n"),
577 ctx->pos); 587 plugin_name);
578 GNUNET_free (plugin_name); 588 GNUNET_free (plugin_name);
589 GNUNET_break (0);
579 return 0; 590 return 0;
580 } 591 }
581 if (GNUNET_OK != 592 if (GNUNET_OK !=
@@ -585,8 +596,8 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
585 &addr, 596 &addr,
586 &addr_len)) 597 &addr_len))
587 { 598 {
588 GNUNET_free (plugin_name); 599 GNUNET_free (plugin_name);
589 return GNUNET_SYSERR; 600 return 0;
590 } 601 }
591 /* address.peer is unset - not used by add_address() */ 602 /* address.peer is unset - not used by add_address() */
592 haddr.address_length = addr_len; 603 haddr.address_length = addr_len;
@@ -620,6 +631,7 @@ parse_hello_uri (const char *put_uri)
620 return GNUNET_SYSERR; 631 return GNUNET_SYSERR;
621 pks = &put_uri[strlen (HELLO_URI_PREFIX)]; 632 pks = &put_uri[strlen (HELLO_URI_PREFIX)];
622 exc = strstr (pks, "!"); 633 exc = strstr (pks, "!");
634
623 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pks, 635 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pks,
624 (NULL == exc) ? strlen (pks) : (exc - pks), 636 (NULL == exc) ? strlen (pks) : (exc - pks),
625 (unsigned char *) &my_public_key, 637 (unsigned char *) &my_public_key,