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
Prevents memory underflow in GFileMimeType() in gutils/fsys.c #5018
Conversation
Are you sure that's where it's crashing? strrchr gets the last occurrence, so it seems to me that |
Or "a.". @Omnikron13 I think the easy fix here is to remove what you added and then below at the start of the
to something like
|
Just Files with single character extensions like I believe that just this:
Should be sufficient to handle it that way. Is there a particular reason to return The only concern I can think of is that this would misidentify any file that ends with just |
gutils/fsys.c
Outdated
@@ -1039,6 +1039,11 @@ char* GFileMimeType(const char *path) { | |||
} else { | |||
pt = copy(pt + 1); | |||
int len = strlen(pt); | |||
|
|||
// Handle the .. 'directory'. Prevents underflowing below | |||
if(len < 1) |
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.
Don't think this is correct, what if you had a file named foo.
.
Can you just change the below check to if(len > 0 && pt[len - 1] == '~')
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.
as above
Short-circuits out the function in the specific case of '..', which was under-flowing the later check
if (pt[len - 1] == '~')
Type of change