]> git.ipfire.org Git - thirdparty/libbsd.git/commit
Fix heap buffer overflow in fgetwln()
authorHanno Boeck <hanno@hboeck.de>
Wed, 27 Jan 2016 14:10:11 +0000 (15:10 +0100)
committerGuillem Jover <guillem@hadrons.org>
Wed, 27 Jan 2016 14:24:50 +0000 (15:24 +0100)
commitc8f0723d2b4520bdd6b9eb7c3e7976de726d7ff7
treefd1467c416fe9f05956a3d77e302930344b5a3e8
parent008316aa291e0930eba067ed7b0772d0009813b0
Fix heap buffer overflow in fgetwln()

In the function fgetwln() there's a 4 byte heap overflow.

There is a while loop that has this check to see whether there's still
enough space in the buffer:

if (!fb->len || wused > fb->len) {

If this is true more memory gets allocated. However this test won't be
true if wused == fb->len, but at that point wused already points out
of the buffer. Some lines later there's a write to the buffer:

fb->wbuf[wused++] = wc;

This bug was found with the help of address sanitizer.

Warned-by: ASAN
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93881
Signed-off-by: Guillem Jover <guillem@hadrons.org>
src/fgetwln.c