Compare commits

...

5 Commits
0.8.1 ... 0.8.2

Author SHA1 Message Date
Guillem Jover
2fb148a290 Release libbsd 0.8.2 2016-01-27 15:25:23 +01:00
Hanno Boeck
c8f0723d2b 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>
2016-01-27 15:24:50 +01:00
Hanno Boeck
008316aa29 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@hadrons.org>
2016-01-27 15:24:39 +01:00
Guillem Jover
e4ab2c62cd test: Fix success return code for arc4random unit test 2016-01-11 02:35:34 +01:00
Lukas Fleischer
bf5573f86c test: Fix race condition in headers-*.sh
When running tests in parallel (e.g. using `make -j4 check`), the header
tests currently fail due to headers-overlay.sh and headers-system.sh
both generating headers-gen.c simultaneously, resulting in garbled
output. Fix this by using separate C files for the tests.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2016-01-10 17:36:34 +01:00
6 changed files with 11 additions and 8 deletions

View File

@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
LIBBSD_ABI_MAJOR=0 LIBBSD_ABI_MAJOR=0
LIBBSD_ABI_MINOR=8 LIBBSD_ABI_MINOR=8
LIBBSD_ABI_PATCH=1 LIBBSD_ABI_PATCH=2
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH" LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
AC_SUBST([LIBBSD_ABI]) AC_SUBST([LIBBSD_ABI])

View File

@@ -60,7 +60,7 @@ fgetwln(FILE *stream, size_t *lenp)
fb->fp = stream; fb->fp = stream;
while ((wc = fgetwc(stream)) != WEOF) { while ((wc = fgetwc(stream)) != WEOF) {
if (!fb->len || wused > fb->len) { if (!fb->len || wused >= fb->len) {
wchar_t *wp; wchar_t *wp;
if (fb->len) if (fb->len)

View File

@@ -99,6 +99,8 @@ main(int argc, char **argv)
/* XXX: We should probably FAIL the test, but we currently /* XXX: We should probably FAIL the test, but we currently
* have one test always failing. */ * have one test always failing. */
rc = TEST_SKIP; rc = TEST_SKIP;
} else {
rc = TEST_OK;
} }
return rc; return rc;

View File

@@ -12,14 +12,14 @@ incdir="${top_srcdir}/include/bsd"
CPPFLAGS="$CPPFLAGS -DLIBBSD_OVERLAY" CPPFLAGS="$CPPFLAGS -DLIBBSD_OVERLAY"
for inc in $(cd $incdir; find -name '*.h' | sort | cut -c3-); do for inc in $(cd $incdir; find -name '*.h' | sort | cut -c3-); do
cat >headers-gen.c <<SOURCE cat >headers-overlay-gen.c <<SOURCE
#include <$inc> #include <$inc>
int main() { return 0; } int main() { return 0; }
SOURCE SOURCE
echo "testing header $inc" echo "testing header $inc"
run $CC -isystem "$incdir" $CPPFLAGS headers-gen.c -o /dev/null run $CC -isystem "$incdir" $CPPFLAGS headers-overlay-gen.c -o /dev/null
echo echo
rm -f headers-gen* rm -f headers-overlay-gen*
done done

View File

@@ -11,14 +11,14 @@ run()
incdir="${top_srcdir}/include" incdir="${top_srcdir}/include"
for inc in $(cd $incdir; find -name '*.h' | sort | cut -c3-); do for inc in $(cd $incdir; find -name '*.h' | sort | cut -c3-); do
cat >headers-gen.c <<SOURCE cat >headers-system-gen.c <<SOURCE
#include <$inc> #include <$inc>
int main() { return 0; } int main() { return 0; }
SOURCE SOURCE
echo "testing header $inc" echo "testing header $inc"
run $CC -isystem "$incdir" $CPPFLAGS headers-gen.c -o /dev/null run $CC -isystem "$incdir" $CPPFLAGS headers-system-gen.c -o /dev/null
echo echo
rm -f headers-gen.* rm -f headers-system-gen.*
done done

View File

@@ -24,6 +24,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>