Building crrcsim v0.9.13 for Fedora produces the following warning[1]:
g++ -DHAVE_CONFIG_H -I. -pthread -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -frounding-math -DPU_USE_SDL -DCRRC_DATA_PATH="\"/usr/share/crrcsim\"" -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -Dlinux -Wall -c -o crrcsim-aircraft.o `test -f 'src/aircraft.cpp' || echo './'`src/aircraft.cpp src/crrc_system.cpp: In function 'char* getOSVersionString()': src/crrc_system.cpp:177:8: warning: '%s' directive output may be truncated writing up to 64 bytes into a region of size between 62 and 126 [-Wformat-truncation=] char * getOSVersionString() ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:862:0, from /usr/include/c++/7/cstdio:42, from /usr/include/c++/7/ext/string_conversions.h:43, from /usr/include/c++/7/bits/basic_string.h:6347, from /usr/include/c++/7/string:52, from src/crrc_system.h:55, from src/crrc_system.cpp:52: /usr/include/bits/stdio2.h:65:44: note: '__builtin___snprintf_chk' output between 2 and 130 bytes into a destination of size 127 __bos (__s), __fmt, __va_arg_pack ()); ^
[1] https://kojipkgs.fedoraproject.org//work/tasks/2391/23822391/build.log
I don't really understand this warning. I'm using snprintf to explicitly truncate the output at the end of the buffer, yet I receive a warning that output is truncated? Hmm, I tend to disable this warning.
The other option would be to enlarge the target buffer by setting OSVERSIONSTRINGBUFFERLEN (line 91) to something like 256 or 512. Could you please try if that helps?
It means that content from sysname and release fields requires 130 bytes but you have only 127.
If you don't have any plans for dynamically allocate the buffer and prefer to keep the following define untouched:
then please consider to use the following patch: