WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

Building m4 with hardened flags

View: New views
3 Messages — Rating Filter:   Alert me  

Building m4 with hardened flags

by Santiago Vila :: Rate this Message:

| View Threaded | Show Only this Message

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.


Re: Building m4 with hardened flags

by eblake :: Rate this Message:

| View Threaded | Show Only this Message

On 05/06/2012 06:06 AM, Santiago Vila wrote:

> 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?
This is no bug, but a result of you trying to use more compiler flags
than the unit test was designed for.  This issue was already raised on
the gnulib list (the owner of the unit test in question), and the
decision was to do nothing:
https://lists.gnu.org/archive/html/bug-gnulib/2012-04/msg00016.html

--
Eric Blake   eblake@...    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc (633 bytes) Download Attachment

Re: Building m4 with hardened flags

by Santiago Vila :: Rate this Message:

| View Threaded | Show Only this Message

On Mon, 7 May 2012, Eric Blake wrote:

> On 05/06/2012 06:06 AM, Santiago Vila wrote:
> > 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?
>
> This is no bug, but a result of you trying to use more compiler flags
> than the unit test was designed for.  This issue was already raised on
> the gnulib list (the owner of the unit test in question), and the
> decision was to do nothing:
> https://lists.gnu.org/archive/html/bug-gnulib/2012-04/msg00016.html

Ok, I agree with that, so I've disabled format string checking.

Thanks a lot.