Fix parsing chunk size with leading zeroes

fix #496
This commit is contained in:
Vinnie Falco
2017-06-15 10:25:42 -07:00
parent 5808fa247b
commit dba4be01ab
3 changed files with 21 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Version 58:
* basic_parser::put doc
* Use static string in basic_fields::reader
* Remove redundant code
* Fix parsing chunk size with leading zeroes
API Changes:

View File

@ -267,7 +267,7 @@ protected:
break;
auto const v0 = v;
v = 16 * v + d;
if(v <= v0)
if(v < v0)
return false;
}
return true;

View File

@ -1054,6 +1054,24 @@ public:
});
}
// https://github.com/vinniefalco/Beast/issues/496
void
testIssue496()
{
// The bug affected hex parsing with leading zeroes
bufgrind<test_parser<false>>(
"HTTP/1.1 200 OK\r\n"
"Transfer-Encoding: chunked\r\n"
"Content-Type: application/octet-stream\r\n"
"\r\n"
"0004\r\nabcd\r\n"
"0\r\n\r\n"
,[&](test_parser<false> const& p)
{
BEAST_EXPECT(p.body == "abcd");
});
}
//--------------------------------------------------------------------------
void
@ -1072,6 +1090,7 @@ public:
testSplit();
testIssue430();
testIssue452();
testIssue496();
testBufGrind();
}
};