From: Jouni Malinen Date: Sun, 8 May 2022 14:09:08 +0000 (+0300) Subject: Simplify DSCP policy parsing X-Git-Tag: hostap_2_11~1913 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6e04a0676d44821a1908e784ff6999cd30cb349;p=thirdparty%2Fhostap.git Simplify DSCP policy parsing Make the bounds checking easier for static analyzers to understand. Signed-off-by: Jouni Malinen --- diff --git a/wpa_supplicant/robust_av.c b/wpa_supplicant/robust_av.c index 770c8fcab..eb97b9c8e 100644 --- a/wpa_supplicant/robust_av.c +++ b/wpa_supplicant/robust_av.c @@ -1301,11 +1301,17 @@ void wpas_handle_qos_mgmt_recv_action(struct wpa_supplicant *wpa_s, attr = qos_ie + 6; rem_attrs_len = qos_ie[1] - 4; - while (rem_attrs_len > 2 && rem_attrs_len >= 2 + attr[1]) { - wpas_fill_dscp_policy(&policy, attr[0], attr[1], - &attr[2]); - rem_attrs_len -= 2 + attr[1]; - attr += 2 + attr[1]; + while (rem_attrs_len > 2) { + u8 attr_id, attr_len; + + attr_id = *attr++; + attr_len = *attr++; + rem_attrs_len -= 2; + if (attr_len > rem_attrs_len) + break; + wpas_fill_dscp_policy(&policy, attr_id, attr_len, attr); + rem_attrs_len -= attr_len; + attr += attr_len; } rem_len -= ie_len;