From: Christian Grothoff Date: Fri, 26 Aug 2016 12:49:15 +0000 (+0000) Subject: fix missing 0-termination X-Git-Tag: initial-import-from-subversion-38251~337 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=00360860690de6b43b64ca9c3d52cbe3fe354bbe;p=oweals%2Fgnunet.git fix missing 0-termination --- 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.