You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compilation of G_recursive_remove complains about "'%s' directive writing up to 255 bytes into a region of size between 1 and 4095" with -Wformat-overflow for sprintf(path2, "%s/%s", path, dp->d_name);.
To reproduce
Run compilation with -Wformat-overflow= (using GCC v13?) or in the nix develop environment.
Expected behavior
No errors or warnings, possibly warnings treated as errors.
Screenshots
gcc -g -O2 -fPIC -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DGRASS_VERSION_DATE=\"'2024'\" -DPACKAGE=\""grasslibs"\" -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"lib/gis\" -o OBJ.x86_64-pc-linux-gnu/set_window.o -c set_window.c
gcc -g -O2 -fPIC -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DGRASS_VERSION_DATE=\"'2024'\" -DPACKAGE=\""grasslibs"\" -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"lib/gis\" -o OBJ.x86_64-pc-linux-gnu/short_way.o -c short_way.c
remove.c: In function 'G_recursive_remove':
remove.c:132:28: warning: '%s' directive writing up to 255 bytes into a region of size between 1 and 4095 [-Wformat-overflow=]
132 | sprintf(path2, "%s/%s", path, dp->d_name);
| ^~
In file included from /nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/stdio.h:980,
from remove.c:15:
In function 'sprintf',
inlined from 'G_recursive_remove' at remove.c:132:9:
/nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/bits/stdio2.h:30:10: note: '__builtin___sprintf_chk' output between 2 and 4351 bytes into a destination of size 4096
30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
gcc -g -O2 -fPIC -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DGRASS_VERSION_DATE=\"'2024'\" -DPACKAGE=\""grasslibs"\" -I/.../grass/dist.x86_64-pc-linux-gnu/include -I/.../grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"lib/gis\" -o OBJ.x86_64-pc-linux-gnu/sleep.o -c sleep.c
Describe the bug
Compilation of G_recursive_remove complains about "'%s' directive writing up to 255 bytes into a region of size between 1 and 4095" with
-Wformat-overflow
forsprintf(path2, "%s/%s", path, dp->d_name);
.To reproduce
Run compilation with
-Wformat-overflow=
(using GCC v13?) or in thenix develop
environment.Expected behavior
No errors or warnings, possibly warnings treated as errors.
Screenshots
System description
nix develop
environment on Ubuntu 22.04.Additional context
The text was updated successfully, but these errors were encountered: