Skip to content

Commit aef819b

Browse files
committed
Uniformly use IEEE802_11_TSTAMP_LEN as the 802.11 timestamp length and
IEEE802_11_AP_LEN as the length of the previous AP in reassociation frame. Before copying variable-length fields from a management frame IE, make sure the length isn't too large.
1 parent b6ede8c commit aef819b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

ieee802_11.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9 2003-07-22 17:36:57 guy Exp $ (LBL) */
1+
/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.1 2005-10-17 07:59:17 guy Exp $ (LBL) */
22
/*
33
* Copyright (c) 2001
44
* Fortress Technologies
@@ -199,12 +199,12 @@ struct tim_t {
199199

200200

201201
struct mgmt_body_t {
202-
u_int8_t timestamp[8];
202+
u_int8_t timestamp[IEEE802_11_TSTAMP_LEN];
203203
u_int16_t beacon_interval;
204204
u_int16_t listen_interval;
205205
u_int16_t status_code;
206206
u_int16_t aid;
207-
u_char ap[6];
207+
u_char ap[IEEE802_11_AP_LEN];
208208
u_int16_t reason_code;
209209
u_int16_t auth_alg;
210210
u_int16_t auth_trans_seq_num;

print-802_11.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#ifndef lint
2424
static const char rcsid[] _U_ =
25-
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.5 2005-07-30 21:37:50 guy Exp $ (LBL)";
25+
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.6 2005-10-17 07:59:18 guy Exp $ (LBL)";
2626
#endif
2727

2828
#ifdef HAVE_CONFIG_H
@@ -132,6 +132,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
132132
offset += 2;
133133
if (pbody->ssid.length <= 0)
134134
break;
135+
if (pbody->ssid.length > 32)
136+
return 0;
135137
if (!TTEST2(*(p + offset), pbody->ssid.length))
136138
return 0;
137139
memcpy(&pbody->ssid.ssid, p + offset,
@@ -146,6 +148,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
146148
offset += 2;
147149
if (pbody->challenge.length <= 0)
148150
break;
151+
if (pbody->challenge.length > 253)
152+
return 0;
149153
if (!TTEST2(*(p + offset), pbody->challenge.length))
150154
return 0;
151155
memcpy(&pbody->challenge.text, p + offset,
@@ -160,6 +164,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
160164
offset += 2;
161165
if (pbody->rates.length <= 0)
162166
break;
167+
if (pbody->rates.length > 8)
168+
return 0;
163169
if (!TTEST2(*(p + offset), pbody->rates.length))
164170
return 0;
165171
memcpy(&pbody->rates.rate, p + offset,
@@ -190,6 +196,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
190196

191197
if (pbody->tim.length <= 3)
192198
break;
199+
if (pbody->rates.length > 251)
200+
return 0;
193201
if (!TTEST2(*(p + offset), pbody->tim.length - 3))
194202
return 0;
195203
memcpy(pbody->tim.bitmap, p + (pbody->tim.length - 3),
@@ -223,7 +231,7 @@ handle_beacon(const u_char *p)
223231
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
224232
IEEE802_11_CAPINFO_LEN))
225233
return 0;
226-
memcpy(&pbody.timestamp, p, 8);
234+
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
227235
offset += IEEE802_11_TSTAMP_LEN;
228236
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
229237
offset += IEEE802_11_BCNINT_LEN;

0 commit comments

Comments
 (0)