Skip to content

Commit 8b42353

Browse files
Deomid Ryabkovcesantabot
authored andcommitted
Check HTTP chunk size, ensure it's reasonable
CL: mg: Check HTTP chunk size, ensure it's reasonable PUBLISHED_FROM=d9f6babd314c092b42ce9e7fe31d6b30a38366a2
1 parent 05c687e commit 8b42353

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

mongoose.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,6 +6311,10 @@ static size_t mg_http_parse_chunk(char *buf, size_t len, char **chunk_data,
63116311
n *= 16;
63126312
n += (s[i] >= '0' && s[i] <= '9') ? s[i] - '0' : tolower(s[i]) - 'a' + 10;
63136313
i++;
6314+
if (i > 6) {
6315+
/* Chunk size is unreasonable. */
6316+
return 0;
6317+
}
63146318
}
63156319

63166320
/* Skip new line */

src/mg_http.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ static size_t mg_http_parse_chunk(char *buf, size_t len, char **chunk_data,
564564
n *= 16;
565565
n += (s[i] >= '0' && s[i] <= '9') ? s[i] - '0' : tolower(s[i]) - 'a' + 10;
566566
i++;
567+
if (i > 6) {
568+
/* Chunk size is unreasonable. */
569+
return 0;
570+
}
567571
}
568572

569573
/* Skip new line */

0 commit comments

Comments
 (0)