Bug 1541359 - frozen-bubble-2.2.1-0.22.beta1.fc28 FTBFS: server/log.c:64:54: error: '%03d' directive output may be truncated
Summary: frozen-bubble-2.2.1-0.22.beta1.fc28 FTBFS: server/log.c:64:54: error: '%03d' ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: frozen-bubble
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: David King
QA Contact: Fedora Extras Quality Assurance
URL: https://apps.fedoraproject.org/kosche...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-02 11:30 UTC by Petr Pisar
Modified: 2018-02-08 13:14 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-02-08 13:14:42 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Proposed fix (2.09 KB, patch)
2018-02-02 11:54 UTC, Petr Pisar
no flags Details | Diff

Description Petr Pisar 2018-02-02 11:30:50 UTC
frozen-bubble-2.2.1-0.22.beta1.fc28 fails to build in F28:

gcc -I/usr/lib64/perl5/CORE -fPIC -g -Wall -Werror -pipe -Iserver -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0 -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -g -o server/log.o server/log.c
server/log.c: In function 'get_current_date':
server/log.c:64:54: error: '%03d' directive output may be truncated writing between 3 and 11 bytes into a region of size between 0 and 49 [-Werror=format-truncation=]
     snprintf(current_date, sizeof(current_date), "%s.%03d", buf, (int)(1000 * (time-seconds)));
                                                      ^~~~
In file included from /usr/include/stdio.h:862,
                 from server/log.c:22:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 5 and 62 bytes into a destination of size 50
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A difference between passing and failing build root is <https://apps.fedoraproject.org/koschei/build/4092289>. This is probably triggered by a glibc or gcc upgrade.

Comment 1 Petr Pisar 2018-02-02 11:54:49 UTC
Created attachment 1390111 [details]
Proposed fix

Comment 2 Hans de Goede 2018-02-07 12:15:38 UTC
Hi Petr,

Did you test the fix fixes the compile error? The error says: "may be truncated writing between 3 and 11 bytes" but you are only making 4 bytes guaranteed available in current_date by shrinking buf from 50 to 46 bytes. So it would seem to me the compiler will still complain?

Regards,

Hans

Comment 3 Petr Pisar 2018-02-07 14:45:48 UTC
Yes, I tested it and the warning went away.

The warning is buggy. It looks like the compiler interferes correctly that current_date is short of 4 bytes because the warning disappears exactly when trimming buf[] from 47 to 46.

Comment 4 Hans de Goede 2018-02-08 13:14:42 UTC
Ok, I've increased current_date to a sizeof 70 just to be sure and kicked off a build. Thank you for the patch.


Note You need to log in before you can comment on or make changes to this bug.