-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: buffer overflow in multipart body proc #3546
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
base: v3/master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -362,11 +362,11 @@ int Multipart::parse_content_disposition(const char *c_d_value, int offset) { | |||||||||||||||||||
| const char* start_of_filename = p; | ||||||||||||||||||||
| while ((*p != '\0') && (*p != ';')) { | ||||||||||||||||||||
| if (*p == '%') { | ||||||||||||||||||||
| if ((*(p+1) == '\0') || (!isxdigit(*(p+1))) || (!isxdigit(*(p+2)))) { | ||||||||||||||||||||
| if ((*(p+1) == '\0') || (!isxdigit(*(p+1))) || (*(p+2) == '\0') || (!isxdigit(static_cast<unsigned char>(*(p+2))))) { | ||||||||||||||||||||
| return -18; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| p += 3; | ||||||||||||||||||||
| } else if (isalnum(*p) || strchr(attr_char_special, *p)) { | ||||||||||||||||||||
| } else if (isalnum(static_cast<unsigned char>(*p)) || strchr(attr_char_special, *p)) { | ||||||||||||||||||||
| p++; | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| return -19; | ||||||||||||||||||||
|
|
@@ -415,7 +415,12 @@ int Multipart::parse_content_disposition(const char *c_d_value, int offset) { | |||||||||||||||||||
| value.append((p++), 1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| p++; /* go over the quote at the end */ | ||||||||||||||||||||
| if (*p == quote) { | ||||||||||||||||||||
| p++; /* go over the quote at the end */ | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| m_flag_invalid_quoting = 1; | ||||||||||||||||||||
| return -15; /* closing quote not found */ | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+418
to
424
|
||||||||||||||||||||
| if (*p == quote) { | |
| p++; /* go over the quote at the end */ | |
| } | |
| if (*p == '\0') { | |
| /* missing terminating quote */ | |
| return -7; | |
| } | |
| p++; /* go over the quote at the end */ |
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.
I'm not sure this is a valid case, multipart header can contain urlencoded text, but the parser's task process it as is.
This suggestion removes that very important condition, I'm afraid that could make the parser wrong.
Uh oh!
There was an error while loading. Please reload this page.