-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Potential invalid access in strncpy0 #107
Comments
Thanks for the report -- you're dead right! I actually had this
Sure enough, changing it introduced an invalid access! I switched to using a manual loop: which will fix this issue, presumably the gcc warnings with Let me know if you see any issues with this, otherwise I'll tag a new release soon. |
Oh, for what it's worth, I was able to repro this fairly easily with a line with lots of spaces and then a section tag, like This change fixes it because the line will always be NUL-terminated (the new code looks for the NUL terminator, just like strncpy did). |
So in the end you implemented strncpy, just to squelch a warning (IMHO a false positive). Please look at the new PR, if contains my fix (which already was in the old one), there no new search for |
Hello,
at (around) line 176 you call:
which will do the same as:
but you don't know that
start
hassizeof(section) - 1
bytes accessible (you are just lucky that this is likely). You would need to take the minimum of characters available instart
as an upper bound.You have the end calculated a line above, so why not do something like:
The text was updated successfully, but these errors were encountered: