1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1508, check the chunk header length.

This commit is contained in:
winlin 2019-12-20 14:51:01 +08:00
parent 4382ced3bf
commit 2b51cee3ef

View file

@ -962,11 +962,16 @@ srs_error_t SrsHttpResponseReader::read_chunked(char* data, int nb_data, int* nb
// it's ok to set the pos and pos+1 to NULL.
at[length - 1] = 0;
at[length - 2] = 0;
// The at is length in string, it must be all digital.
if (!srs_is_digit_number(at)) {
return srs_error_new(ERROR_HTTP_INVALID_CHUNK_HEADER, "invalid length=%s", at);
}
// size is the bytes size, excludes the chunk header and end CRLF.
int ilength = (int)::strtol(at, NULL, 16);
if (ilength < 0) {
return srs_error_new(ERROR_HTTP_INVALID_CHUNK_HEADER, "invalid length=%d", ilength);
return srs_error_new(ERROR_HTTP_INVALID_CHUNK_HEADER, "invalid length=%s as %d", at, ilength);
}
// all bytes in chunk is left now.