Skip to content

Commit 8092c70

Browse files
committed
Use UINT64_MAX instead of UINT_MAX for invalid lengths
1 parent fc2b7be commit 8092c70

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
@@ -1,5 +1,5 @@
11
/*
2-
* Authored by Alex Hultman, 2018-2020.
2+
* Authored by Alex Hultman, 2018-2024.
33
* Intellectual property of third-party.
44
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -199,18 +199,18 @@ struct HttpParser {
199199
/* This guy really has only 30 bits since we reserve two highest bits to chunked encoding parsing state */
200200
uint64_t remainingStreamingBytes = 0;
201201

202-
/* Returns UINT_MAX on error. Maximum 999999999 is allowed. */
202+
/* Returns UINT64_MAX on error. Maximum 999999999 is allowed. */
203203
static uint64_t toUnsignedInteger(std::string_view str) {
204204
/* We assume at least 64-bit integer giving us safely 999999999999999999 (18 number of 9s) */
205205
if (str.length() > 18) {
206-
return UINT_MAX;
206+
return UINT64_MAX;
207207
}
208208

209209
uint64_t unsignedIntegerValue = 0;
210210
for (char c : str) {
211211
/* As long as the letter is 0-9 we cannot overflow. */
212212
if (c < '0' || c > '9') {
213-
return UINT_MAX;
213+
return UINT64_MAX;
214214
}
215215
unsignedIntegerValue = unsignedIntegerValue * 10ull + ((unsigned int) c - (unsigned int) '0');
216216
}
@@ -517,7 +517,7 @@ struct HttpParser {
517517
}
518518
} else if (contentLengthString.length()) {
519519
remainingStreamingBytes = toUnsignedInteger(contentLengthString);
520-
if (remainingStreamingBytes == UINT_MAX) {
520+
if (remainingStreamingBytes == UINT64_MAX) {
521521
/* Parser error */
522522
return {HTTP_ERROR_400_BAD_REQUEST, FULLPTR};
523523
}

0 commit comments

Comments
 (0)