aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ieee80211.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-02-25 09:31:07 +0000
committerGuy Harris <guy@alum.mit.edu>2004-02-25 09:31:07 +0000
commit857318d3b760aa1ee27b9025746e1f39ce946a53 (patch)
tree4e9d5900443b375741a9966dee096dee52c01a1c /packet-ieee80211.c
parent3353ca1d5a8307ce1ae6afd49b3f7525596e0910 (diff)
Use "tvb_get_string()" instead of allocating a (len+1)-sized buffer,
"tvb_memcpy()"ing to it, and putting in a null terminator; "tvb_get_string()" will check whether all bytes of the string are present before allocating the buffer, so that you don't leak memory if the copy throws an exception, and don't crash if the length is absurdly large. Use "tvb_memdup()" instead of allocating a buffer and "tvb_memcpy()"ing to it, so that an exception is thrown before you try to allocate the buffer (for the same reasons as listed above). Before allocating a buffer used when processing a chunk of data from a packet, get a pointer to the chunk with "tvb_get_ptr()", or check that the data is all there with "tvb_ensure_bytes_exist()", so that an exception is thrown before you try to allocate the buffer (for the same reasons as listed above). Fix up the lengths of the tvbuff used when dissecting ONC RPC opaque data with a particular dissector. svn path=/trunk/; revision=10236
Diffstat (limited to 'packet-ieee80211.c')
-rw-r--r--packet-ieee80211.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/packet-ieee80211.c b/packet-ieee80211.c
index d01d8b0ed6..9da0196d77 100644
--- a/packet-ieee80211.c
+++ b/packet-ieee80211.c
@@ -3,7 +3,7 @@
* Copyright 2000, Axis Communications AB
* Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
*
- * $Id: packet-ieee80211.c,v 1.105 2004/02/18 07:56:42 guy Exp $
+ * $Id: packet-ieee80211.c,v 1.106 2004/02/25 09:31:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -2626,6 +2626,7 @@ proto_reg_handoff_ieee80211(void)
}
static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
+ const guint8 *enc_data;
guint8 *tmp = NULL;
int i;
tvbuff_t *decr_tvb = NULL;
@@ -2633,6 +2634,8 @@ static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
if (num_wepkeys < 1)
return NULL;
+ enc_data = tvb_get_ptr(tvb, offset, len);
+
if ((tmp = g_malloc(len)) == NULL)
return NULL; /* krap! */
@@ -2642,7 +2645,7 @@ static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
#if 0
printf("trying %d\n", i);
#endif
- tvb_memcpy(tvb, tmp, offset, len);
+ memcpy(tmp, enc_data, len);
if (wep_decrypt(tmp, len, i) == 0) {
/* decrypt successful, let's set up a new data tvb. */