Skip to content
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

/home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:77:5: error: ‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of length 199 [-Werror=stringop-truncation] 77 | strncpy(dest, src, size); #104

Closed
mohitj1988 opened this issue May 13, 2020 · 6 comments

Comments

@mohitj1988
Copy link

mohitj1988 commented May 13, 2020

Hi,
I am using gcc latest version 10.1.0 and using the latest version inih (inih-r49) .
I am getting errors during make

In file included from /usr/include/string.h:633,
from /home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:20:
In function ‘strncpy0’,
inlined from ‘ini_parse_stream’ at /home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:199:17:
/home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:77:5: error: ‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of length 199 [-Werror=stringop-truncation]
77 | strncpy(dest, src, size - 1);
| ^~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [src/third_party/inih++/lib/CMakeFiles/inih++.dir/ini.c.o] Error 1
make[1]: *** [src/third_party/inih++/lib/CMakeFiles/inih++.dir/all] Error 2
make: *** [all] Error 2

Please fix this or suggest a work-around until this gets fixed

@mohitj1988 mohitj1988 changed the title /home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:55:3: error: ‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of length 199 [-Werror=stringop-truncation] 55 | strncpy(dest, src, size); /home/mohit.joshi/pstress_ps/src/third_party/inih++/lib/ini.c:77:5: error: ‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of length 199 [-Werror=stringop-truncation] 77 | strncpy(dest, src, size); May 14, 2020
@benhoyt
Copy link
Owner

benhoyt commented May 15, 2020

Hmm, this has come up a couple of times (#91 and #90), so I should really get to the bottom of it and fix it. I still believe the code is doing the right thing, but maybe I need to change to memcpy to avoid the warning/error. I'll dig into it further in the next week or so.

@mohitj1988
Copy link
Author

Thanks. I will wait for you to come to a conclusion.

@benhoyt
Copy link
Owner

benhoyt commented Jun 4, 2020

That commit should fix it. Can you please verify, and if so, I'll tag a release?

@mohitj1988
Copy link
Author

Hello,
Using memcpy instead of strncpy works fine! Please go ahead and tag a release.
Thank you!

mohitj1988 added a commit to Percona-QA/pstress that referenced this issue Jun 8, 2020
Details: benhoyt/inih#104

The fix has been included in pstress
@benhoyt
Copy link
Owner

benhoyt commented Jun 8, 2020

@benhoyt benhoyt closed this as completed Jun 8, 2020
@benhoyt
Copy link
Owner

benhoyt commented Jun 19, 2020

Unfortunately the straight switch to memcpy introduced a "read from invalid memory" issue. Fixed with https://github.com/benhoyt/inih/releases/tag/r51 in a way that hopefully avoids the gcc warning as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants