aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-03 12:16:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-03 12:16:22 +0000
commite7dcc206d3644f49a494370c36757704369b7007 (patch)
tree12f60b23fe4af52525f245e9bc09419d39a27241
parentbc04203f71e022e30d53a411f9c49a0a0a9890ef (diff)
downloadgnunet-e7dcc206d3644f49a494370c36757704369b7007.tar.gz
gnunet-e7dcc206d3644f49a494370c36757704369b7007.zip
-fix
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c12
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index 86e5d4684..476b403a5 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -80,18 +80,22 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
80 const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *in; 80 const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *in;
81 size_t payload_size; 81 size_t payload_size;
82 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage newheader; 82 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage newheader;
83 uint16_t sendsize;
83 84
85 sendsize = ntohs (hdr->size);
84 in = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; 86 in = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;
85 if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) || 87 if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
86 (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) < ntohs (hdr->size)) ) 88 (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
87 { 89 {
88 fprintf (stderr, "Function stdin_send: wrong packet type or size\n"); 90 fprintf (stderr, "Received malformed message\n",
91 (unsigned int) sendsize,
92 (unsigned int) ntohs (hdr->type));
89 exit (1); 93 exit (1);
90 } 94 }
91 payload_size = ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage); 95 payload_size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
92 if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2) 96 if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2)
93 { 97 {
94 fprintf (stderr, "Function stdin_send: Packet too big for buffer\n"); 98 fprintf (stderr, "Packet too big for buffer\n");
95 exit (1); 99 exit (1);
96 } 100 }
97 memset (&newheader, 0, sizeof (newheader)); 101 memset (&newheader, 0, sizeof (newheader));
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 3b5e0b1ab..2d68c3655 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -1803,7 +1803,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1803 sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)); 1803 sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame));
1804 if (MAXLINE < sendsize) 1804 if (MAXLINE < sendsize)
1805 { 1805 {
1806 fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n"); 1806 fprintf (stderr, "Packet too big for buffer\n");
1807 exit (1); 1807 exit (1);
1808 } 1808 }
1809 header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; 1809 header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;