-fix
authorChristian Grothoff <christian@grothoff.org>
Tue, 3 Apr 2012 12:16:22 +0000 (12:16 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 3 Apr 2012 12:16:22 +0000 (12:16 +0000)
src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-helper-transport-wlan.c

index 86e5d4684e072d98544225b7cd59c11a175aa863..476b403a50f19bcb0adeb35d59c2ebd503282fb9 100644 (file)
@@ -80,18 +80,22 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
   const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *in;
   size_t payload_size;
   struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage newheader;
+  uint16_t sendsize;
 
+  sendsize = ntohs (hdr->size);
   in = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;
   if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
-       (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) < ntohs (hdr->size)) )
+       (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
   {
-    fprintf (stderr, "Function stdin_send: wrong packet type or size\n");
+    fprintf (stderr, "Received malformed message\n",
+            (unsigned int) sendsize,
+            (unsigned int) ntohs (hdr->type));
     exit (1);
   }
-  payload_size = ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
+  payload_size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
   if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2)
   {
-    fprintf (stderr, "Function stdin_send: Packet too big for buffer\n");
+    fprintf (stderr, "Packet too big for buffer\n");
     exit (1);
   }
   memset (&newheader, 0, sizeof (newheader));
index 3b5e0b1aba5903c3cbca13f870f39440319c3251..2d68c3655d0d513547e0073e9ed3eb9f9a686bc8 100644 (file)
@@ -1803,7 +1803,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
   sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame));
   if (MAXLINE < sendsize)
   {
-    fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n");
+    fprintf (stderr, "Packet too big for buffer\n");
     exit (1);
   }
   header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;