Fix potential buffer underflow and inefficient copy using fnmatch.#261
Open
robert-ancell wants to merge 1 commit into
Open
Fix potential buffer underflow and inefficient copy using fnmatch.#261robert-ancell wants to merge 1 commit into
robert-ancell wants to merge 1 commit into
Conversation
3925137 to
8c6ff04
Compare
hughsie
reviewed
Aug 29, 2018
hughsie
reviewed
Aug 29, 2018
| if (text_sz != -1 && text[text_sz-1] != '\0') { | ||
| if (text_sz == 0) | ||
| return FNM_NOMATCH; | ||
| if (text[text_sz-1] != '\0') { |
Owner
There was a problem hiding this comment.
Why not just?
if (text_sz != 0 && text[text_sz-1] != '\0') {
Collaborator
Author
There was a problem hiding this comment.
Because a zero length buffer might not be nul terminated.
Owner
|
CI seems to be failing -- can you check than out pls? |
Owner
8c6ff04 to
5ba4d1b
Compare
If length was zero we could check the -1 index. A nul was always added because we only used the length of the string, not the buffer (i.e. off by one). Also remove a check for a negative number from an unsigned number.
5ba4d1b to
e32ad92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If length was zero we could check the -1 index.
A nul was always added because we only used the length of the string, not the
buffer (i.e. off by one).
Also remove a check for a negative number from an unsigned number.