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

Fix potential buffer underflow and inefficient copy using fnmatch. #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robert-ancell
Copy link
Collaborator

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.

if (text_sz != -1 && text[text_sz-1] != '\0') {
if (text_sz == 0)
return FNM_NOMATCH;
if (text[text_sz-1] != '\0') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just?

	if (text_sz != 0 && text[text_sz-1] != '\0') {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because a zero length buffer might not be nul terminated.

@hughsie
Copy link
Owner

hughsie commented Aug 30, 2018

CI seems to be failing -- can you check than out pls?

@hughsie
Copy link
Owner

hughsie commented Feb 6, 2019

@robert-ancell ?

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.
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

Successfully merging this pull request may close these issues.

2 participants