Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that, at least for the string in
bufcomming from a correct*cupsFilter(2): ...line, the crash cannot have been caused by the string pointed at byptrbeing too long forbuf, asptris pointing somewhere intobuf. The problem is that, according to the man page,strcpy()is not suitable for copying overlapping strings/buffers, and so that could have caused the crash here.Now, with the replacement by
snprintf()the crash has gone away in this particular case, but here the man page also says that this function is not suitable for overlapping strings/buffers, so one should expect that a crash still can happen in other situations.To be safe one could eaither do a
for()loop moving the characters to the beginning of the buffer one-by-one or thememmove()function which according to its man page supports overlapping memory areas.could be used here and should work reliably, at least if buf contains a correctly
\0-terminated string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strlen(ptr) + 1(to also move the terminating nul character)