| 1 | diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
|
|---|
| 2 | index 0e0b3a2..595791d 100644
|
|---|
| 3 | --- a/src/http/ngx_http_parse.c
|
|---|
| 4 | +++ b/src/http/ngx_http_parse.c
|
|---|
| 5 | @@ -104,6 +104,7 @@ ngx_int_t
|
|---|
| 6 | ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|---|
| 7 | {
|
|---|
| 8 | u_char c, ch, *p, *m;
|
|---|
| 9 | + ngx_uint_t cpt=0;
|
|---|
| 10 | enum {
|
|---|
| 11 | sw_start = 0,
|
|---|
| 12 | sw_method,
|
|---|
| 13 | @@ -723,6 +724,7 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | r->http_major = ch - '0';
|
|---|
| 17 | + cpt = 1;
|
|---|
| 18 | state = sw_major_digit;
|
|---|
| 19 | break;
|
|---|
| 20 |
|
|---|
| 21 | @@ -733,11 +735,12 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|---|
| 22 | break;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | - if (ch < '0' || ch > '9') {
|
|---|
| 26 | + if (ch < '0' || ch > '9' || cpt > 3) {
|
|---|
| 27 | return NGX_HTTP_PARSE_INVALID_REQUEST;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | r->http_major = r->http_major * 10 + ch - '0';
|
|---|
| 31 | + cpt++;
|
|---|
| 32 | break;
|
|---|
| 33 |
|
|---|
| 34 | /* first digit of minor HTTP version */
|
|---|
| 35 | @@ -747,6 +750,7 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | r->http_minor = ch - '0';
|
|---|
| 39 | + cpt = 1;
|
|---|
| 40 | state = sw_minor_digit;
|
|---|
| 41 | break;
|
|---|
| 42 |
|
|---|
| 43 | @@ -766,11 +770,12 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|---|
| 44 | break;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | - if (ch < '0' || ch > '9') {
|
|---|
| 48 | + if (ch < '0' || ch > '9' || cpt > 3) {
|
|---|
| 49 | return NGX_HTTP_PARSE_INVALID_REQUEST;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | r->http_minor = r->http_minor * 10 + ch - '0';
|
|---|
| 53 | + cpt++;
|
|---|
| 54 | break;
|
|---|
| 55 |
|
|---|
| 56 | case sw_spaces_after_digit:
|
|---|
| 57 |
|
|---|
| 58 | -----------------------------8372063701935580560345663874
|
|---|
| 59 | Content-Disposition: form-data; name="description"
|
|---|
| 60 |
|
|---|
| 61 | limit number of supported digits in http major version to avoid int16 overflow leading to 0 in major verion |
|---|