Skip to content
Browse files

Check for lookbehind buffer underflows too.

  • Loading branch information...
1 parent 15d9581 commit 4a6475f60e785641e7293a1944a1c81ef5e4f1b2 @FooBarWidget committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 multipart.cpp
View
9 multipart.cpp
@@ -134,7 +134,7 @@ class MultipartParser {
headerFieldMark = UNMARKED;
headerValueMark = UNMARKED;
partDataMark = UNMARKED;
- errorReason = NULL;
+ errorReason = "Parser uninitialized.";
onPartBegin = NULL;
onHeaderField = NULL;
@@ -339,8 +339,13 @@ class MultipartParser {
// when matching a possible boundary, keep a lookbehind reference
// in case it turns out to be a false lead
if (index - 1 >= lookbehindSize) {
- setError("Internal error");
+ setError("Parser bug: index overflows lookbehind buffer. "
+ "Please send bug report with input file attached.");
throw std::out_of_range("index overflows lookbehind buffer");
+ } else if (index - 1 < 0) {
+ setError("Parser bug: index underflows lookbehind buffer. "
+ "Please send bug report with input file attached.");
+ throw std::out_of_range("index underflows lookbehind buffer");
}
lookbehind[index - 1] = c;
} else if (prevIndex > 0) {

0 comments on commit 4a6475f

Please sign in to comment.
Something went wrong with that request. Please try again.