From: Eric Blake Date: Mon, 8 Jun 2009 12:17:39 +0000 (-0600) Subject: test-strstr: use memory fence, when possible X-Git-Tag: v0.1~5876 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=294cd32bcabea638d959dc004073800842e85ad6;p=gnulib.git test-strstr: use memory fence, when possible * tests/test-strstr.c (main): Use memory fence, in order to be more likely to trigger Debian bug 521737. * modules/strstr-tests (Files): Pull in additional files. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 729f727bc..34f4b6e52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-06-08 Eric Blake + test-strstr: use memory fence, when possible + * tests/test-strstr.c (main): Use memory fence, in order to be + more likely to trigger Debian bug 521737. + * modules/strstr-tests (Files): Pull in additional files. + memchr: no longer obsolete, for wider field testing * modules/memchr (Status, Notice): Delete, this module is no longer obsolete. diff --git a/modules/strstr-tests b/modules/strstr-tests index 23e67b014..8f09e58f5 100644 --- a/modules/strstr-tests +++ b/modules/strstr-tests @@ -1,12 +1,18 @@ Files: tests/test-strstr.c +tests/zerosize-ptr.h +m4/mmap-anon.m4 Depends-on: +extensions +getpagesize configure.ac: AC_CHECK_DECLS_ONCE([alarm]) +gl_FUNC_MMAP_ANON +AC_CHECK_HEADERS_ONCE([sys/mman.h]) +AC_CHECK_FUNCS_ONCE([mprotect]) Makefile.am: TESTS += test-strstr check_PROGRAMS += test-strstr - diff --git a/tests/test-strstr.c b/tests/test-strstr.c index f7bc4cb91..37f4bace6 100644 --- a/tests/test-strstr.c +++ b/tests/test-strstr.c @@ -24,6 +24,8 @@ #include #include +#include "zerosize-ptr.h" + #define ASSERT(expr) \ do \ { \ @@ -68,13 +70,16 @@ main (int argc, char *argv[]) This is a bug in memchr(), see the Austin Group's clarification . */ const char *fix = "aBaaaaaaaaaaax"; - char *input = malloc (strlen (fix) + 1); + char *page_boundary = (char *) zerosize_ptr (); + size_t len = strlen (fix) + 1; + char *input = page_boundary ? page_boundary - len : malloc (len); const char *result; strcpy (input, fix); result = strstr (input, "B1x"); ASSERT (result == NULL); - free (input); + if (!page_boundary) + free (input); } {