3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

erp: Fix off by one error

The intent of this check is to make sure that at least 2 bytes are
available for reading.  However, the unintended consequence is that tags
with a zero length at the end of input would be rejected.

While here, rework the check to be more resistant to potential
overflow conditions.
This commit is contained in:
Denis Kenzior 2022-01-14 10:22:41 -06:00
parent 938e056896
commit eddcc4c5b6

View File

@ -117,7 +117,7 @@ static bool erp_tlv_iter_next(struct erp_tlv_iter *iter)
unsigned int tag;
unsigned int len;
if (iter->pos + 2 >= iter->max)
if (end - tlv < 2)
return false;
tag = *tlv++;