mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()
authorTakashi Iwai <tiwai@suse.de>
Fri, 31 May 2019 13:18:41 +0000 (15:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Jul 2019 07:04:32 +0000 (09:04 +0200)
commitb1459fb34061337efbf0d47a3ba6208f2f59829d
treed43d5350b77248232cc47ac164bafeefabef7a53
parentebd45bdd74ffe4e199e5af39b4d7765059419a9c
mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()

commit 69ae4f6aac1578575126319d3f55550e7e440449 upstream.

A few places in mwifiex_uap_parse_tail_ies() perform memcpy()
unconditionally, which may lead to either buffer overflow or read over
boundary.

This patch addresses the issues by checking the read size and the
destination size at each place more properly.  Along with the fixes,
the patch cleans up the code slightly by introducing a temporary
variable for the token size, and unifies the error path with the
standard goto statement.

Reported-by: huangwen <huangwen@venustech.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/marvell/mwifiex/ie.c