make gnunet-service-peerinfo unlink HELLOs greater than the allowed GNUNET_MAX_MESSAG...
authorxrs <xrs@mail36.net>
Sun, 17 Dec 2017 17:31:36 +0000 (18:31 +0100)
committerxrs <xrs@mail36.net>
Sun, 17 Dec 2017 17:31:36 +0000 (18:31 +0100)
src/peerinfo/gnunet-service-peerinfo.c

index 731c24bf1fc57783a127c5fc21f2f10047697c3e..af1eb2d1d6e6566716d559b11676a13f989fbb7f 100644 (file)
@@ -987,9 +987,13 @@ discard_hosts_helper (void *cls,
   int write_pos;
   unsigned int cnt;
   char *writebuffer;
+  uint64_t fsize;
 
+  GNUNET_DISK_file_size (fn, &fsize, GNUNET_YES, GNUNET_YES);
   read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
-  if (read_size < (int) sizeof (struct GNUNET_MessageHeader))
+
+  if ((read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
+      (fsize > GNUNET_MAX_MESSAGE_SIZE))
   {
     if (0 != UNLINK (fn))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |