From: Jouni Malinen Date: Sun, 31 Mar 2013 18:58:17 +0000 (+0300) Subject: Optimize Extended Capabilities element to be of minimal length X-Git-Tag: aosp-kk-from-upstream~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3db5439a5f87ccd6cc128ca588dae67766d25b97;p=thirdparty%2Fhostap.git Optimize Extended Capabilities element to be of minimal length Leave out zero octets from the end of the element. Signed-hostap: Jouni Malinen --- diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c index e59ac1322..c36bbe399 100644 --- a/src/ap/ieee802_11_shared.c +++ b/src/ap/ieee802_11_shared.c @@ -239,7 +239,14 @@ u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid) } } - return pos; + while (len > 0 && eid[1 + len] == 0) { + len--; + eid[1] = len; + } + if (len == 0) + return eid; + + return eid + 2 + len; } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index cac824426..c6b45f3b2 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1231,7 +1231,14 @@ int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf) } } - return pos - buf; + while (len > 0 && buf[1 + len] == 0) { + len--; + buf[1] = len; + } + if (len == 0) + return 0; + + return 2 + len; }