mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #192] gcc 8 warnings #154
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeroen on GitHub (Aug 21, 2018).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/192
Originally assigned to: @jmcnamara on GitHub.
@jmcnamara commented on GitHub (Aug 21, 2018):
What is the exact
gcc --version?The warnings look spurious to me but I'll install gcc 8.2 and check.
@jeroen commented on GitHub (Aug 21, 2018):
The warnings appear both on Fedora 28 and Debian Buster with the current gcc: https://cran.r-project.org/web/checks/check_results_writexl.html
Yes the warnings are silly, but my repo maintainers insist that all code compiles without warnings even with
-Wall -pedantic. The fix is easy: you just need to increase the buffer size by 1 so that there is no theoretical case where the terminating\0gets dropped when copying a string (even if this will never actually happen).@jmcnamara commented on GitHub (Aug 21, 2018):
Nope. That isn't the case if you look at the code and the buffers involved (at least for the xmlwriter warnings. The tmpfileplus isn't my code but it looks like it is properly terminating the buffer).
Older gccs, clang, ICC, TCC, scan-build and coverity don't complain about this. So I still think it is spurious and also probably not fixable.
@jeroen commented on GitHub (Aug 21, 2018):
Well it's not entirely spurious. The definition of strncat is: Appends the first num characters of source to destination, plus a terminating null-character. However you are doing this:
For example here
LXW_AMPis 6 bytes and youstrncatit with a limit of 5, sostrncat()never makes it to the null terminator of the input string, and it warns about that. Maybe you should usememcpy()?Yes I know, gcc 8 introduces a bunch of new compiler warnings that try to enforce some best practices in preventing buffer overflows when it comes to copying strings. We've seen similar warnings in many libraries, they are usually easy to fix.
@jmcnamara commented on GitHub (Aug 21, 2018):
That's not what it is complaining about though. At least as far as I can see. The
-Wstringop-overflow=error is about the destination buffer.Anyway, I'll need to do some testing with gcc8 to see what can be done.
@jeroen commented on GitHub (Aug 21, 2018):
The error actually says it is about the source
‘strncat’ specified bound 5 equals source length@jmcnamara commented on GitHub (Aug 21, 2018):
Okay. That is different. In that case it may be valid. Either way I'll look in to it.
@jmcnamara commented on GitHub (Aug 22, 2018):
I've push a fix for this to master. I also fixed some warnings in the third party libraries that are embedded in the source tree.
I tested it with gcc 8.2.0 and 9.0.0 so we should be warning free for a while.
Thanks for the report. Let me know if you need it tagged in a release for cran and I can do that in the next few days.