WFD: Use cleaner bounds checking for sub-element length field
Mark the variable as unsigned and make the length check use "len > end - pos" version to makes this easier to understand for static analyzers (CID 74155). Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
c061ae590a
commit
4debeb42a6
1 changed files with 2 additions and 2 deletions
|
@ -271,7 +271,7 @@ int wifi_display_subelem_set_from_ies(struct wpa_global *global,
|
||||||
{
|
{
|
||||||
int subelements[MAX_WFD_SUBELEMS] = {};
|
int subelements[MAX_WFD_SUBELEMS] = {};
|
||||||
const u8 *pos, *end;
|
const u8 *pos, *end;
|
||||||
int len, subelem;
|
unsigned int len, subelem;
|
||||||
struct wpabuf *e;
|
struct wpabuf *e;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "WFD IEs set: %p - %lu",
|
wpa_printf(MSG_DEBUG, "WFD IEs set: %p - %lu",
|
||||||
|
@ -292,7 +292,7 @@ int wifi_display_subelem_set_from_ies(struct wpa_global *global,
|
||||||
wpa_printf(MSG_DEBUG, "WFD Sub-Element ID %d - len %d",
|
wpa_printf(MSG_DEBUG, "WFD Sub-Element ID %d - len %d",
|
||||||
*pos, len - 3);
|
*pos, len - 3);
|
||||||
|
|
||||||
if (pos + len > end)
|
if (len > end - pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
subelem = *pos;
|
subelem = *pos;
|
||||||
|
|
Loading…
Reference in a new issue