aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-11 12:22:57 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-11 12:22:57 +0000
commit23c5ad04c768190d178518ada3fccf7d39d676b7 (patch)
tree8048ce377faeafa48d6ccd4050a548c550f90cdd /src
parent30b74c15b7f76b0371495f79447a8aaebcc71636 (diff)
downloadgnunet-23c5ad04c768190d178518ada3fccf7d39d676b7.tar.gz
gnunet-23c5ad04c768190d178518ada3fccf7d39d676b7.zip
- iterator NULL check
- do no empty name if it did not exist before
Diffstat (limited to 'src')
-rw-r--r--src/namestore/gnunet-service-namestore.c54
-rw-r--r--src/namestore/plugin_namestore_sqlite.c4
2 files changed, 32 insertions, 26 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index b58f43613..fda19cacf 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -613,16 +613,15 @@ handle_record_store (void *cls,
613 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 613 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
614 return; 614 return;
615 } 615 }
616 { 616 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
617 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
618 617
619 if (GNUNET_OK != 618 if (GNUNET_OK !=
620 GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) 619 GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd))
621 { 620 {
622 GNUNET_break (0); 621 GNUNET_break (0);
623 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 622 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
624 return; 623 return;
625 } 624 }
626 625
627 /* Extracting and converting private key */ 626 /* Extracting and converting private key */
628 GNUNET_CRYPTO_ecc_key_get_public (&rp_msg->private_key, 627 GNUNET_CRYPTO_ecc_key_get_public (&rp_msg->private_key,
@@ -640,6 +639,14 @@ handle_record_store (void *cls,
640 (unsigned int) rd_count, 639 (unsigned int) rd_count,
641 conv_name, 640 conv_name,
642 GNUNET_NAMESTORE_z2s (&pubkey)); 641 GNUNET_NAMESTORE_z2s (&pubkey));
642
643 if ((rd_count == 0) && (GNUNET_NO == GSN_database->iterate_records (GSN_database->cls, &rp_msg->private_key, 0, NULL, 0)))
644 {
645 /* This name does not exist, so cannot be removed */
646 res = GNUNET_NO;
647 }
648 else
649 {
643 res = GSN_database->store_records (GSN_database->cls, 650 res = GSN_database->store_records (GSN_database->cls,
644 &rp_msg->private_key, 651 &rp_msg->private_key,
645 conv_name, 652 conv_name,
@@ -650,35 +657,34 @@ handle_record_store (void *cls,
650 struct GNUNET_NAMESTORE_Block *block; 657 struct GNUNET_NAMESTORE_Block *block;
651 658
652 if (0 == rd_count) 659 if (0 == rd_count)
653 block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, 660 block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
654 GNUNET_TIME_UNIT_ZERO_ABS, 661 GNUNET_TIME_UNIT_ZERO_ABS,
655 conv_name, 662 conv_name,
656 rd, rd_count); 663 rd, rd_count);
657 else 664 else
658 block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, 665 block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
659 GNUNET_TIME_UNIT_FOREVER_ABS, 666 GNUNET_TIME_UNIT_FOREVER_ABS,
660 conv_name, 667 conv_name,
661 rd, rd_count); 668 rd, rd_count);
662 if (GNUNET_OK != 669 if (GNUNET_OK !=
663 GSN_database->cache_block (GSN_database->cls, 670 GSN_database->cache_block (GSN_database->cls,
664 block)) 671 block))
665 { 672 {
666 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 673 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
667 _("Failed to cache encrypted block of my own zone!\n")); 674 _("Failed to cache encrypted block of my own zone!\n"));
668 res = GNUNET_SYSERR; 675 res = GNUNET_SYSERR;
669 } 676 }
670 GNUNET_free (block); 677 GNUNET_free (block);
671 678
672 for (zm = monitor_head; NULL != zm; zm = zm->next) 679 for (zm = monitor_head; NULL != zm; zm = zm->next)
673 if (0 == memcmp (&rp_msg->private_key, 680 if (0 == memcmp (&rp_msg->private_key, &zm->zone,
674 &zm->zone, 681 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
675 sizeof (struct GNUNET_CRYPTO_EccPrivateKey))) 682 send_lookup_response (monitor_nc,
676 send_lookup_response (monitor_nc, 683 zm->nc->client,
677 zm->nc->client, 684 zm->request_id,
678 zm->request_id, 685 &rp_msg->private_key,
679 &rp_msg->private_key, 686 conv_name,
680 conv_name, 687 rd_count, rd);
681 rd_count, rd);
682 } 688 }
683 GNUNET_free (conv_name); 689 GNUNET_free (conv_name);
684 } 690 }
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index b9fcce907..d062c81a1 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -751,8 +751,8 @@ get_record_and_call_iterator (struct Plugin *plugin,
751 } 751 }
752 else if (NULL != zone_key) 752 else if (NULL != zone_key)
753 { 753 {
754 iter (iter_cls, zone_key, label, 754 if (NULL != iter)
755 record_count, rd); 755 iter (iter_cls, zone_key, label, record_count, rd);
756 ret = GNUNET_YES; 756 ret = GNUNET_YES;
757 } 757 }
758 } 758 }