EAP-FAST peer: 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
ed5e3a5888
commit
72bb05a033
2 changed files with 2 additions and 2 deletions
|
@ -1096,7 +1096,7 @@ static int eap_fast_parse_decrypted(struct wpabuf *decrypted,
|
|||
/* Parse TLVs from the decrypted Phase 2 data */
|
||||
pos = wpabuf_mhead(decrypted);
|
||||
end = pos + wpabuf_len(decrypted);
|
||||
while (pos + 4 < end) {
|
||||
while (end - pos > 4) {
|
||||
mandatory = pos[0] & 0x80;
|
||||
tlv_type = WPA_GET_BE16(pos) & 0x3fff;
|
||||
pos += 2;
|
||||
|
|
|
@ -709,7 +709,7 @@ static void eap_fast_pac_get_a_id(struct eap_fast_pac *pac)
|
|||
pos = pac->pac_info;
|
||||
end = pos + pac->pac_info_len;
|
||||
|
||||
while (pos + 4 < end) {
|
||||
while (end - pos > 4) {
|
||||
type = WPA_GET_BE16(pos);
|
||||
pos += 2;
|
||||
len = WPA_GET_BE16(pos);
|
||||
|
|
Loading…
Reference in a new issue