Skip to content

Commit 05fe5bc

Browse files
committed
Allow huge content-lengths
1 parent e039428 commit 05fe5bc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/HttpParser.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,19 @@ struct HttpParser {
183183
uint64_t remainingStreamingBytes = 0;
184184

185185
/* Returns UINT_MAX on error. Maximum 999999999 is allowed. */
186-
static unsigned int toUnsignedInteger(std::string_view str) {
187-
/* We assume at least 32-bit integer giving us safely 999999999 (9 number of 9s) */
188-
if (str.length() > 9) {
186+
static uint64_t toUnsignedInteger(std::string_view str) {
187+
/* We assume at least 64-bit integer giving us safely 999999999999999999 (18 number of 9s) */
188+
if (str.length() > 18) {
189189
return UINT_MAX;
190190
}
191191

192-
unsigned int unsignedIntegerValue = 0;
192+
uint64_t unsignedIntegerValue = 0;
193193
for (char c : str) {
194194
/* As long as the letter is 0-9 we cannot overflow. */
195195
if (c < '0' || c > '9') {
196196
return UINT_MAX;
197197
}
198-
unsignedIntegerValue = unsignedIntegerValue * 10u + ((unsigned int) c - (unsigned int) '0');
198+
unsignedIntegerValue = unsignedIntegerValue * 10ull + ((unsigned int) c - (unsigned int) '0');
199199
}
200200
return unsignedIntegerValue;
201201
}

0 commit comments

Comments
 (0)