Interworking: Clearer ANQP element length validation
The upper bound for the element length was already verified, but that was not apparently noticed by a static analyzer (CID 68128). Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b81e274cdf
commit
43aee94899
1 changed files with 5 additions and 2 deletions
|
@ -2808,7 +2808,9 @@ void anqp_resp_cb(void *ctx, const u8 *dst, u8 dialog_token,
|
||||||
end = pos + wpabuf_len(resp);
|
end = pos + wpabuf_len(resp);
|
||||||
|
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
if (pos + 4 > end) {
|
unsigned int left = end - pos;
|
||||||
|
|
||||||
|
if (left < 4) {
|
||||||
wpa_printf(MSG_DEBUG, "ANQP: Invalid element");
|
wpa_printf(MSG_DEBUG, "ANQP: Invalid element");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2816,7 +2818,8 @@ void anqp_resp_cb(void *ctx, const u8 *dst, u8 dialog_token,
|
||||||
pos += 2;
|
pos += 2;
|
||||||
slen = WPA_GET_LE16(pos);
|
slen = WPA_GET_LE16(pos);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
if (pos + slen > end) {
|
left -= 4;
|
||||||
|
if (left < slen) {
|
||||||
wpa_printf(MSG_DEBUG, "ANQP: Invalid element length "
|
wpa_printf(MSG_DEBUG, "ANQP: Invalid element length "
|
||||||
"for Info ID %u", info_id);
|
"for Info ID %u", info_id);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue