glrpt icon indicating copy to clipboard operation
glrpt copied to clipboard

Possible buffer overflow warnings detected by compiler building under Ubuntu 20.04

Open magore opened this issue 4 years ago • 1 comments

FYI - The program does compile and install but issues warning that might be worth looking at

[ 86%] Building C object src/CMakeFiles/glrpt.dir/glrpt/utils.c.o /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.c: In function ‘File_Name’: /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.c:177:13: warning: ‘%s’ directive output may be truncated writing up to 19 bytes into a region of size between 0 and 4096 [-Wformat-truncation=] 177 | "%s/%s-Ch%u%s", glrpt_img_dir, tim, chn, ext ); | ^~ ~~~ In file included from /usr/include/stdio.h:867, from /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.h:25, from /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.c:17: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output 6 or more bytes (assuming 4121) into a destination of size 4097 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.c:174:13: warning: ‘%s’ directive output may be truncated writing up to 19 bytes into a region of size between 0 and 4096 [-Wformat-truncation=] 174 | "%s/%s-Combo%s", glrpt_img_dir, tim, ext ); | ^~ ~~~ In file included from /usr/include/stdio.h:867, from /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.h:25, from /share/embedded/SDR/METEOR/glrpt/src/glrpt/utils.c:17: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output 8 or more bytes (assuming 4123) into a destination of size 4097 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

magore avatar Oct 08 '20 01:10 magore

Yes, these warnings are triggered because of -D_FORTIFY_SOURCE=2 flag during compilation. I'm going to rework that part soon. Thank you for reminding it!

dvdesolve avatar Oct 08 '20 04:10 dvdesolve