From: Christian Grothoff Date: Sun, 27 Jun 2010 13:13:07 +0000 (+0000) Subject: properly check for gnd files X-Git-Tag: initial-import-from-subversion-38251~21191 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=269edcfc22cea65fda93c958ddc97033a292acf9;p=oweals%2Fgnunet.git properly check for gnd files --- diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index 03065958e..6698ad010 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c @@ -201,10 +201,16 @@ GNUNET_FS_directory_list_contents (size_t size, struct GNUNET_CONTAINER_MetaData *md; char *filename; + if ( (offset == 0) && + ( (size < 8 + sizeof (uint32_t)) || + (0 != memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8)) ) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("MAGIC mismatch. This is not a GNUnet directory.\n")); + return GNUNET_SYSERR; + } pos = offset; - if ( (pos == 0) && - (size >= 8 + sizeof (uint32_t)) && - (0 == memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8)) ) + if (offset == 0) { memcpy (&mdSize, &cdata[8], sizeof (uint32_t)); mdSize = ntohl (mdSize);