-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strncpy and snprintf bounds checks #150
Comments
tpetazzoni
added a commit
to tpetazzoni/libfaketime
that referenced
this issue
May 17, 2018
gcc 8.x introduced stricter checking on strncpy(), and causes the following build failures: libfaketime.c: In function 'fake_clock_gettime.part.4': libfaketime.c:2134:7: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time, tmp_env, BUFFERLEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:2134:7: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time, tmp_env, BUFFERLEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c: In function 'ftpl_init': libfaketime.c:1884:12: error: 'strncpy' specified bound 1024 equals destination size [-Werror=stringop-truncation] (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), 1024); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:1945:5: error: 'strncpy' specified bound 8192 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time_fmt, tmp_env, BUFSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c: In function 'ftpl_init': libfaketime.c:1884:12: error: 'strncpy' specified bound 1024 equals destination size [-Werror=stringop-truncation] (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), 1024); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:1945:5: error: 'strncpy' specified bound 8192 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time_fmt, tmp_env, BUFSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This commit fixes that by making sure we keep one final byte for the nul terminator, as suggested by wolfcw#150. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
fixed by 0d96436 , thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
over in https://bugs.debian.org/891551, James Cowgill writes:
The text was updated successfully, but these errors were encountered: