libbsd: Branch 'master' - 3 commits

Guillem Jover guillem at kemper.freedesktop.org
Wed Jan 27 08:05:13 PST 2016


 configure.ac   |    2 +-
 src/fgetwln.c  |    2 +-
 test/strmode.c |    1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 2fb148a290c1677dcf09ada4379583e244a92014
Author: Guillem Jover <guillem at hadrons.org>
Date:   Wed Jan 27 15:25:23 2016 +0100

    Release libbsd 0.8.2

diff --git a/configure.ac b/configure.ac
index 7faa05c..d334774 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
 
 LIBBSD_ABI_MAJOR=0
 LIBBSD_ABI_MINOR=8
-LIBBSD_ABI_PATCH=1
+LIBBSD_ABI_PATCH=2
 
 LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
 AC_SUBST([LIBBSD_ABI])
commit c8f0723d2b4520bdd6b9eb7c3e7976de726d7ff7
Author: Hanno Boeck <hanno at hboeck.de>
Date:   Wed Jan 27 15:10:11 2016 +0100

    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 at hadrons.org>

diff --git a/src/fgetwln.c b/src/fgetwln.c
index 9ee0776..aa3f927 100644
--- a/src/fgetwln.c
+++ b/src/fgetwln.c
@@ -60,7 +60,7 @@ fgetwln(FILE *stream, size_t *lenp)
 	fb->fp = stream;
 
 	while ((wc = fgetwc(stream)) != WEOF) {
-		if (!fb->len || wused > fb->len) {
+		if (!fb->len || wused >= fb->len) {
 			wchar_t *wp;
 
 			if (fb->len)
commit 008316aa291e0930eba067ed7b0772d0009813b0
Author: Hanno Boeck <hanno at hboeck.de>
Date:   Wed Jan 27 15:06:50 2016 +0100

    test: Add missing <sys/stat.h> include
    
    The test in test/strmode.c can fail to compile depending on the
    optimization flags used.
    
    The constants that are used in this file (S_IFREG etc.) come from the
    <sys/stat.h> include file. It seems gcc ignores this error if one
    compiles with "-O2" (default), but if one uses no optimization it fails.
    
    Add the missing include and it works all the time.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93880
    Signed-off-by: Guillem Jover <guillem at hadrons.org>

diff --git a/test/strmode.c b/test/strmode.c
index 2584c27..405ace1 100644
--- a/test/strmode.c
+++ b/test/strmode.c
@@ -24,6 +24,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/stat.h>
 #include <assert.h>
 #include <string.h>
 


More information about the libbsd mailing list