From fd9ed7b5a3e296ad99e39c36d011d5a9db6f46dd Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 29 Feb 2012 09:59:50 +0000 Subject: [PATCH] - changes --- src/namestore/namestore_common.c | 13 +++++++++++++ src/namestore/test_namestore_api_lookup.c | 18 ++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index 711230351..44c8110bb 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c @@ -128,6 +128,12 @@ GNUNET_NAMESTORE_records_deserialize ( struct GNUNET_NAMESTORE_RecordData **dest uint32_t data_size; int c; + if (len == 0) + { + (*dest) = NULL; + return 0; + } + offset = 0; elements = 0; while (offset < len) @@ -141,6 +147,13 @@ GNUNET_NAMESTORE_records_deserialize ( struct GNUNET_NAMESTORE_RecordData **dest elements ++; } + if (elements == 0) + { + (*dest) = NULL; + return 0; + } + + GNUNET_assert (len == offset); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserializing %i records with total length of %u\n", elements, len); diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c index 2ec589a20..0841fb216 100644 --- a/src/namestore/test_namestore_api_lookup.c +++ b/src/namestore/test_namestore_api_lookup.c @@ -122,17 +122,26 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void name_lookup_proc (void *cls, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, struct GNUNET_TIME_Absolute expire, - const char *name, + const char *n, unsigned int rd_count, const struct GNUNET_NAMESTORE_RecordData *rd, const struct GNUNET_CRYPTO_RsaSignature *signature) { - if (name != NULL) + static int found = GNUNET_NO; + + if (n != NULL) + { + found = GNUNET_YES; res = 0; + } else { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to lookup records for name `%s'\n", zone_key, name, rd_count, rd, signature); - res = 1; + if (found != GNUNET_YES) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", name); + res = 1; + } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup done for name %s'\n", name); } GNUNET_SCHEDULER_add_now(&end, NULL); @@ -152,6 +161,7 @@ put_cont (void *cls, int32_t success, const char *emsg) else { res = 1; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); GNUNET_SCHEDULER_add_now(&end, NULL); } } -- 2.25.1