gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 23c5ad04c768190d178518ada3fccf7d39d676b7
parent 30b74c15b7f76b0371495f79447a8aaebcc71636
Author: Matthias Wachs <wachs@net.in.tum.de>
Date:   Wed, 11 Sep 2013 12:22:57 +0000

- iterator NULL check
- do no empty name if it did not exist before


Diffstat:
Msrc/namestore/gnunet-service-namestore.c | 54++++++++++++++++++++++++++++++------------------------
Msrc/namestore/plugin_namestore_sqlite.c | 4++--
2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c @@ -613,16 +613,15 @@ handle_record_store (void *cls, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - { - struct GNUNET_NAMESTORE_RecordData rd[rd_count]; + struct GNUNET_NAMESTORE_RecordData rd[rd_count]; - if (GNUNET_OK != - GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) - { - GNUNET_break (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); - return; - } + if (GNUNET_OK != + GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } /* Extracting and converting private key */ GNUNET_CRYPTO_ecc_key_get_public (&rp_msg->private_key, @@ -640,6 +639,14 @@ handle_record_store (void *cls, (unsigned int) rd_count, conv_name, GNUNET_NAMESTORE_z2s (&pubkey)); + + if ((rd_count == 0) && (GNUNET_NO == GSN_database->iterate_records (GSN_database->cls, &rp_msg->private_key, 0, NULL, 0))) + { + /* This name does not exist, so cannot be removed */ + res = GNUNET_NO; + } + else + { res = GSN_database->store_records (GSN_database->cls, &rp_msg->private_key, conv_name, @@ -650,35 +657,34 @@ handle_record_store (void *cls, struct GNUNET_NAMESTORE_Block *block; if (0 == rd_count) - block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, + block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, GNUNET_TIME_UNIT_ZERO_ABS, conv_name, rd, rd_count); else - block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, + block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, GNUNET_TIME_UNIT_FOREVER_ABS, conv_name, rd, rd_count); if (GNUNET_OK != - GSN_database->cache_block (GSN_database->cls, + GSN_database->cache_block (GSN_database->cls, block)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to cache encrypted block of my own zone!\n")); - res = GNUNET_SYSERR; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Failed to cache encrypted block of my own zone!\n")); + res = GNUNET_SYSERR; } GNUNET_free (block); for (zm = monitor_head; NULL != zm; zm = zm->next) - if (0 == memcmp (&rp_msg->private_key, - &zm->zone, - sizeof (struct GNUNET_CRYPTO_EccPrivateKey))) - send_lookup_response (monitor_nc, - zm->nc->client, - zm->request_id, - &rp_msg->private_key, - conv_name, - rd_count, rd); + if (0 == memcmp (&rp_msg->private_key, &zm->zone, + sizeof (struct GNUNET_CRYPTO_EccPrivateKey))) + send_lookup_response (monitor_nc, + zm->nc->client, + zm->request_id, + &rp_msg->private_key, + conv_name, + rd_count, rd); } GNUNET_free (conv_name); } diff --git 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, } else if (NULL != zone_key) { - iter (iter_cls, zone_key, label, - record_count, rd); + if (NULL != iter) + iter (iter_cls, zone_key, label, record_count, rd); ret = GNUNET_YES; } }