diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-17 08:01:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-17 08:01:38 +0000 |
commit | ad3086c0d4083f4a499936bf6e043edcfc1627c4 (patch) | |
tree | 3425d524243f4d0de23d83c6dd18b93561f2af1c /src/namestore/test_namestore_api_store_update.c | |
parent | 2a0feb1324e62faaec9392d177a1cb6098591555 (diff) | |
download | gnunet-ad3086c0d4083f4a499936bf6e043edcfc1627c4.tar.gz gnunet-ad3086c0d4083f4a499936bf6e043edcfc1627c4.zip |
-fix use after free, cancel of dead task
Diffstat (limited to 'src/namestore/test_namestore_api_store_update.c')
-rw-r--r-- | src/namestore/test_namestore_api_store_update.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/namestore/test_namestore_api_store_update.c b/src/namestore/test_namestore_api_store_update.c index b2506f874..edc11067d 100644 --- a/src/namestore/test_namestore_api_store_update.c +++ b/src/namestore/test_namestore_api_store_update.c | |||
@@ -61,7 +61,7 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
61 | 61 | ||
62 | static struct GNUNET_NAMECACHE_QueueEntry *ncqe; | 62 | static struct GNUNET_NAMECACHE_QueueEntry *ncqe; |
63 | 63 | ||
64 | static const char * name = "dummy.dummy.gnunet"; | 64 | static const char *name = "dummy"; |
65 | 65 | ||
66 | 66 | ||
67 | static void | 67 | static void |
@@ -166,6 +166,8 @@ rd_decrypt_cb (void *cls, | |||
166 | GNUNET_assert (TEST_RECORD_DATALEN2 == rd[0].data_size); | 166 | GNUNET_assert (TEST_RECORD_DATALEN2 == rd[0].data_size); |
167 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN2)); | 167 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN2)); |
168 | 168 | ||
169 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
170 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | ||
169 | GNUNET_SCHEDULER_add_now (&end, NULL); | 171 | GNUNET_SCHEDULER_add_now (&end, NULL); |
170 | } | 172 | } |
171 | } | 173 | } |
@@ -179,16 +181,11 @@ name_lookup_proc (void *cls, | |||
179 | 181 | ||
180 | ncqe = NULL; | 182 | ncqe = NULL; |
181 | GNUNET_assert (NULL != cls); | 183 | GNUNET_assert (NULL != cls); |
182 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
183 | { | ||
184 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
185 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | ||
186 | } | ||
187 | |||
188 | if (NULL == block) | 184 | if (NULL == block) |
189 | { | 185 | { |
190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 186 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
191 | _("Namestore returned no block\n")); | 187 | _("Namecache returned no block for `%s'\n"), |
188 | name); | ||
192 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 189 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
193 | GNUNET_SCHEDULER_cancel (endbadly_task); | 190 | GNUNET_SCHEDULER_cancel (endbadly_task); |
194 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 191 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
@@ -196,7 +193,7 @@ name_lookup_proc (void *cls, | |||
196 | } | 193 | } |
197 | 194 | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
199 | "Namestore returned block, decrypting \n"); | 196 | "Namecache returned block, decrypting \n"); |
200 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block, | 197 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block, |
201 | &pubkey, name, &rd_decrypt_cb, (void *) name)); | 198 | &pubkey, name, &rd_decrypt_cb, (void *) name)); |
202 | } | 199 | } |
@@ -215,7 +212,12 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
215 | name, | 212 | name, |
216 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 213 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
217 | /* Create derived hash */ | 214 | /* Create derived hash */ |
218 | GNUNET_GNSRECORD_query_from_private_key (privkey, name, &derived_hash); | 215 | GNUNET_GNSRECORD_query_from_private_key (privkey, |
216 | name, | ||
217 | &derived_hash); | ||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
219 | "Looking in namecache for `%s'\n", | ||
220 | GNUNET_h2s (&derived_hash)); | ||
219 | ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash, | 221 | ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash, |
220 | &name_lookup_proc, (void *) name); | 222 | &name_lookup_proc, (void *) name); |
221 | } | 223 | } |
@@ -253,14 +255,15 @@ run (void *cls, | |||
253 | GNUNET_break (NULL != nsh); | 255 | GNUNET_break (NULL != nsh); |
254 | nch = GNUNET_NAMECACHE_connect (cfg); | 256 | nch = GNUNET_NAMECACHE_connect (cfg); |
255 | GNUNET_break (NULL != nch); | 257 | GNUNET_break (NULL != nch); |
256 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 258 | nsqe = GNUNET_NAMESTORE_records_store (nsh, |
257 | 1, &rd, &put_cont, (void *) name); | 259 | privkey, name, |
260 | 1, &rd, | ||
261 | &put_cont, (void *) name); | ||
258 | if (NULL == nsqe) | 262 | if (NULL == nsqe) |
259 | { | 263 | { |
260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 264 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
261 | _("Namestore cannot store no block\n")); | 265 | _("Namestore cannot store no block\n")); |
262 | } | 266 | } |
263 | |||
264 | GNUNET_free ((void *)rd.data); | 267 | GNUNET_free ((void *)rd.data); |
265 | } | 268 | } |
266 | 269 | ||