-
Notifications
You must be signed in to change notification settings - Fork 189
error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Werror=stringop-truncation] #297
Comments
@zsong I have run into an identical error. Have you found a solution? |
Replace the strncpy with memcpy |
@tienex Where do I have to replace it? |
The error contains the file name and the line, open that file go to that line and replace it. |
Thanks! |
Thanks it worked. I got it working just to found out that it actually can't build anything on linux haha. |
I just coincidentally walk into here lead by google search. So that the error said the output was truncated before the null terminating, since "ISTC" actually contains 5 chars "I" "S" "T" "C" and 0 (try https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ |
@liangti the intention is to only copy 4 bytes, the Compiled Asset Archive format has magic bytes describing the rendition. A null terminating byte would clobber the next struct member. |
This is entirely pedantic though, and you could also continue to use strncpy() if you'd like by passing -Wno-error=stringop-truncation to your compiler, see CMakeLists.txt and find add_compile_options. |
The text was updated successfully, but these errors were encountered: