Fix off-by-one bounds checking in printf_encode()
authorStuart Henderson <sthen@openbsd.org>
Mon, 2 Jun 2014 12:53:23 +0000 (15:53 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 2 Jun 2014 14:36:18 +0000 (17:36 +0300)
commit5dff6dff63063fa78061fcb6b0931c6e981dd994
tree2328680457a9c84627f72eeba9bb1c946d17b8a5
parent801e117376e13d5b3c50f1627b93a949529fdf99
Fix off-by-one bounds checking in printf_encode()

The off-by-one error in printf_encode() bounds checking could have
allowed buffer overflow with 0x00 being written to the memory position
following the last octet of the target buffer. Since this output is used
as \0-terminated string, the following operation would likely read past
the buffer as well. Either of these operations can result in the process
dying either due to buffer overflow protection or by a read from
unallowed address.

This has been seen to cause wpa_supplicant crash on OpenBSD when control
interface client attaches (debug print shows the client socket address).
Similarly, it may be possible to trigger the issue in RADIUS/EAP server
implementation within hostapd with a suitable constructed user name.

Signed-off-by: Stuart Henderson <sthen@openbsd.org>
src/utils/common.c