« Return to Thread: Building m4 with hardened flags

Building m4 with hardened flags

by Santiago Vila :: Rate this Message:

| View in Thread

Hello.

When trying to build m4 using hardened flags, I found a test that fails:

#1;3001;0c    source='test-xvasprintf.c' object='test-xvasprintf.o' libtool=no
gcc -std=gnu99  -I. -I../lib  -DIN_M4_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../lib -I./../lib -D_FORTIFY_SOURCE=2  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-xvasprintf.c
test-xvasprintf.c: In function 'test_xasprintf':
test-xvasprintf.c:98:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make[6]: *** [test-xvasprintf.o] Error 1

This is the code which fails:

  {
    /* Silence gcc warning about zero-length format string.  */
    const char *empty = "";
    result = xasprintf (empty);
    ASSERT (result != NULL);
    ASSERT (strcmp (result, "") == 0);
    free (result);
  }

Every other test seems to be ok.

What would you recommend? Should I just disable this code and keep "-Werror=format-security"?
Or maybe there is a bug somewhere?

Thanks.

 « Return to Thread: Building m4 with hardened flags