-
Notifications
You must be signed in to change notification settings - Fork 24
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
Compilation error with strncpy #28
Comments
@mohitj1988 Hi! Can you please fix this in the repo? I think you ran into similar in pstress? Thanks |
While at it, please also have a look at #27 if it is correct, and other open tickets. Thank you. |
Yes, I am aware. Thank you! |
Btw, I thought there was some feedback that the memcpy introduced a new bug? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 I had the following error while compiling:
In file included from /usr/include/string.h:519,
from /home/iolalla/src/pquery/src/third_party/inih++/lib/ini.c:12:
In function ‘strncpy’,
inlined from ‘strncpy0’ at /home/iolalla/src/pquery/src/third_party/inih++/lib/ini.c:55:3,
inlined from ‘ini_parse_file’ at /home/iolalla/src/pquery/src/third_party/inih++/lib/ini.c:143:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of length 199 [-Werror=stringop-truncation]
95 | return __builtin___strncpy_chk (__dest, __src, __len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 | __glibc_objsize (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [src/third_party/inih++/lib/CMakeFiles/inih++.dir/build.make:82: src/third_party/inih++/lib/CMakeFiles/inih++.dir/ini.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:196: src/third_party/inih++/lib/CMakeFiles/inih++.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
In order to fix it I changed strncpy with memcpy and compile smoothly:
diff --git a/src/third_party/inih++/lib/ini.c b/src/third_party/inih++/lib/ini.c
index 5228f0d..33d4691 100644
--- a/src/third_party/inih++/lib/ini.c
+++ b/src/third_party/inih++/lib/ini.c
@@ -52,7 +52,7 @@ static char* find_char_or_comment(const char* s, char c) {
/* Version of strncpy that ensures dest (size bytes) is null-terminated. /
static char strncpy0(char* dest, const char* src, size_t size) {
dest[size - 1] = '\0';
return dest;
}
If you prefer I can do a pull request
The text was updated successfully, but these errors were encountered: