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.
Created attachment 1390111 [details] Proposed fix
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
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.
Ok, I've increased current_date to a sizeof 70 just to be sure and kicked off a build. Thank you for the patch.