From 00360860690de6b43b64ca9c3d52cbe3fe354bbe Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 26 Aug 2016 12:49:15 +0000 Subject: fix missing 0-termination --- src/namestore/plugin_namestore_flat.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index b522fc031..869aa3d9f 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c @@ -180,11 +180,11 @@ database_setup (struct Plugin *plugin) afsdir); return GNUNET_SYSERR; } - - if (GNUNET_SYSERR == GNUNET_DISK_file_size (afsdir, - &size, - GNUNET_YES, - GNUNET_YES)) + if (GNUNET_SYSERR == + GNUNET_DISK_file_size (afsdir, + &size, + GNUNET_YES, + GNUNET_YES)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unable to get filesize: %s.\n"), @@ -192,20 +192,21 @@ database_setup (struct Plugin *plugin) return GNUNET_SYSERR; } - buffer = GNUNET_malloc (size); - - if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, - buffer, - size)) + buffer = GNUNET_malloc (size) + 1; + if (GNUNET_SYSERR == + GNUNET_DISK_file_read (fh, + buffer, + size)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unable to read file: %s.\n"), afsdir); return GNUNET_SYSERR; } - GNUNET_DISK_file_close (fh); - if (0 < size) { + + if (0 < size) + { line = strtok (buffer, "\n"); while (line != NULL) { zone_private_key = strtok (line, ","); @@ -347,6 +348,7 @@ store_and_free_entries (void *cls, return GNUNET_YES; } + /** * Shutdown database connection and associate data * structures. -- cgit v1.2.3