authentication of ciphertexts (+ seed)
[oweals/gnunet.git] / src / fs / fs_directory.c
index 03065958e20413e83db4c70282821aaf64ec388d..22419e107b890bfb7e37d07de40192711147e727 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -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);