bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] GCC 7 warnings


From: Pavel Raiskup
Subject: [Bug-tar] GCC 7 warnings
Date: Fri, 08 Sep 2017 08:46:57 +0200

Hello maintainers,

building from git with GCC 7 is a bit more complited again, as gcc 7 is more
-Werror sensitive.  I've attached a patch that looks like worth having
pushed to me.

There's one remaining issue:

        list.c: In function ‘tartime’:
        list.c:1053:33: error: ‘%02d’ directive writing between 2 and 11 bytes 
into a region of size between 4 and 29 [-Werror=format-overflow=]
            sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
                                         ^~~~
        list.c:1053:4: note: ‘sprintf’ output between 20 and 81 bytes into a 
destination of size 37
            sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              tm->tm_hour, tm->tm_min, tm->tm_sec);
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        list.c:1059:31: error: ‘%02d’ directive writing between 2 and 11 bytes 
into a region of size between 4 and 29 [-Werror=format-overflow=]
          sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
                                       ^~~~
        list.c:1059:2: note: ‘sprintf’ output between 17 and 69 bytes into a 
destination of size 37
          sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tm->tm_hour, tm->tm_min);
            ~~~~~~~~~~~~~~~~~~~~~~~~

This is IMO false positive, as long as we can expect that if
"utc_option ? gmtime (&s) : localtime (&s);" succeeds then it returns
valid 'struct tm'.

The warning can be silenced by e.g. min(0, max(9999, tm->tm_year)) hacks or by
ignoring the warning globally/locally by pragma.  Please silence this warning,
or suggest your preferred fix and I'll have a look at it.

Plus, there's gnulib issue [1].

[1] https://www.mail-archive.com/address@hidden/msg34265.html

Pavel

Attachment: 0001-Fix-some-GCC-warnings.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]