mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-02-21 11:33:04 -05:00
ndis: Avoid undefined behavior in pointer arithmetic
Reorder terms in a way that no invalid pointers are generated with pos+len operations. end-pos is always defined (with a valid pos pointer) while pos+len could end up pointing beyond the end pointer which would be undefined behavior. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
d717126aa2
commit
78c8ee488f
@ -785,8 +785,8 @@ static const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie)
|
|||||||
pos = (const u8 *) (res + 1);
|
pos = (const u8 *) (res + 1);
|
||||||
end = pos + res->ie_len;
|
end = pos + res->ie_len;
|
||||||
|
|
||||||
while (pos + 1 < end) {
|
while (end - pos > 1) {
|
||||||
if (pos + 2 + pos[1] > end)
|
if (2 + pos[1] > end - pos)
|
||||||
break;
|
break;
|
||||||
if (pos[0] == ie)
|
if (pos[0] == ie)
|
||||||
return pos;
|
return pos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user