The length of the additional elements was not used correctly, so the
check for remaining tailroom would not have caught cases where there is
not enough remaining room in the buffer and the following
wpabuf_put_data() operation would have resulted in terminating the
process due to the additional check to prevent buffer overflows.
The existing use cases for this function within wpa_supplicant do not
seem to generate buffers that would be even close to reaching this limit
due to large buffer size used for the target. Anyway, this check needs
to be fixed to avoid any potential issues in the future or in external
uses for this function.
Fixes: b1ed44b6a699 ("PASN: Allow extra elements to be added into PASN Authentication frames")
Signed-off-by: Jouni Malinen <jouni.malinen@oss.qualcomm.com>
if (!len || !extra_ies || !buf)
return 0;
- if (wpabuf_tailroom(buf) < sizeof(len))
+ if (wpabuf_tailroom(buf) < len)
return -1;
wpabuf_put_data(buf, extra_ies, len);