aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:26:24 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:26:24 +0000
commite1951cfc02f5b87d0a55c2bba4bfe1bbfa471702 (patch)
treea241c5f2f9d50e962e33f695bea2d787987ec469 /src/namestore
parentadbd23e743ace44072b503b77a7b9a043f1aa674 (diff)
downloadgnunet-e1951cfc02f5b87d0a55c2bba4bfe1bbfa471702.tar.gz
gnunet-e1951cfc02f5b87d0a55c2bba4bfe1bbfa471702.zip
-coverity
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/plugin_namestore_flat.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c
index ca5f3e9a3..4356c3b93 100644
--- a/src/namestore/plugin_namestore_flat.c
+++ b/src/namestore/plugin_namestore_flat.c
@@ -225,18 +225,38 @@ database_setup (struct Plugin *plugin)
225 break; 225 break;
226 line = strtok (NULL, "\n"); 226 line = strtok (NULL, "\n");
227 entry = GNUNET_malloc (sizeof (struct FlatFileEntry)); 227 entry = GNUNET_malloc (sizeof (struct FlatFileEntry));
228 sscanf (rvalue, "%lu", &entry->rvalue); 228 if (1 != sscanf (rvalue, "%lu", &entry->rvalue))
229 sscanf (record_count, "%u", &entry->record_count); 229 {
230 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
231 "Error parsing entry\n");
232 GNUNET_free (entry);
233 break;
234 }
235 if (1 != sscanf (record_count, "%u", &entry->record_count))
236 {
237 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
238 "Error parsing entry\n");
239 GNUNET_free (entry);
240 break;
241 }
230 entry->label = GNUNET_strdup (label); 242 entry->label = GNUNET_strdup (label);
231 record_data_size = GNUNET_STRINGS_base64_decode (record_data_b64, 243 record_data_size = GNUNET_STRINGS_base64_decode (record_data_b64,
232 strlen (record_data_b64), 244 strlen (record_data_b64),
233 &record_data); 245 &record_data);
234 entry->record_data = 246 entry->record_data =
235 GNUNET_malloc (sizeof (struct GNUNET_GNSRECORD_Data) * entry->record_count); 247 GNUNET_malloc (sizeof (struct GNUNET_GNSRECORD_Data) * entry->record_count);
236 GNUNET_GNSRECORD_records_deserialize (record_data_size, 248 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (record_data_size,
237 record_data, 249 record_data,
238 entry->record_count, 250 entry->record_count,
239 entry->record_data); 251 entry->record_data))
252 {
253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
254 "Unable to deserialize record %s\n", label);
255 GNUNET_free (entry->label);
256 GNUNET_free (entry);
257 GNUNET_free (record_data);
258 break;
259 }
240 GNUNET_free (record_data); 260 GNUNET_free (record_data);
241 GNUNET_STRINGS_base64_decode (zone_private_key, 261 GNUNET_STRINGS_base64_decode (zone_private_key,
242 strlen (zone_private_key), 262 strlen (zone_private_key),
@@ -291,7 +311,7 @@ store_and_free_entries (void *cls,
291 &zone_private_key); 311 &zone_private_key);
292 GNUNET_asprintf (&rvalue, "%lu", entry->rvalue); 312 GNUNET_asprintf (&rvalue, "%lu", entry->rvalue);
293 GNUNET_asprintf (&record_count, "%u", entry->record_count); 313 GNUNET_asprintf (&record_count, "%u", entry->record_count);
294 314
295 data_size = GNUNET_GNSRECORD_records_get_size (entry->record_count, 315 data_size = GNUNET_GNSRECORD_records_get_size (entry->record_count,
296 entry->record_data); 316 entry->record_data);
297 char data[data_size]; 317 char data[data_size];
@@ -301,6 +321,9 @@ store_and_free_entries (void *cls,
301 data)) 321 data))
302 { 322 {
303 GNUNET_break (0); 323 GNUNET_break (0);
324 GNUNET_free (zone_private_key);
325 GNUNET_free (rvalue);
326 GNUNET_free (record_count);
304 return GNUNET_SYSERR; 327 return GNUNET_SYSERR;
305 } 328 }
306 GNUNET_STRINGS_base64_encode (data, 329 GNUNET_STRINGS_base64_encode (data,
@@ -468,7 +491,7 @@ namestore_lookup_records (void *cls,
468 key_len, 491 key_len,
469 &hkey); 492 &hkey);
470 GNUNET_free (key); 493 GNUNET_free (key);
471 494
472 entry = GNUNET_CONTAINER_multihashmap_get (plugin->hm, &hkey); 495 entry = GNUNET_CONTAINER_multihashmap_get (plugin->hm, &hkey);
473 496
474 if (NULL == entry) 497 if (NULL == entry)