Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
v3.0.4 - YYYY-MMM-DD (to be released)
-------------------------------------


- Make the boundary check less strict as per RFC2046
[Issue #1943 - @victorhora, @allanbomsft]


v3.0.3 - 2018-Nov-05
Expand Down
52 changes: 19 additions & 33 deletions src/request_body_processor/multipart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,41 +158,27 @@ int Multipart::boundary_characters_valid(const char *boundary) {
}

while ((c = *p) != '\0') {
/* Control characters and space not allowed. */
if (c < 32) {
// Check against allowed list defined in RFC2046 page 22
if (!(
('0' <= c && c <= '9')
|| ('A' <= c && c <= 'Z')
|| ('a' <= c && c <= 'z')
|| (c == ' ' && *(p + 1) != '\0') // space allowed, but not as last character
|| c == '\''
|| c == '('
|| c == ')'
|| c == '+'
|| c == '_'
|| c == ','
|| c == '-'
|| c == '.'
|| c == '/'
|| c == ':'
|| c == '='
|| c == '?'
)) {
return 0;
}

/* Non-ASCII characters not allowed. */
if (c > 126) {
return 0;
}

switch (c) {
/* Special characters not allowed. */
case '(' :
case ')' :
case '<' :
case '>' :
case '@' :
case ',' :
case ';' :
case ':' :
case '\\' :
case '"' :
case '/' :
case '[' :
case ']' :
case '?' :
case '=' :
return 0;
break;

default :
/* Do nothing. */
break;
}

p++;
}

Expand Down
Loading