| Index: net/http/http_chunked_decoder.cc
|
| diff --git a/net/http/http_chunked_decoder.cc b/net/http/http_chunked_decoder.cc
|
| index fab94342adb14e28b857594db1b66d41793343a8..7aa4a965cd707cc705a693863bb75a6f26ef91b1 100644
|
| --- a/net/http/http_chunked_decoder.cc
|
| +++ b/net/http/http_chunked_decoder.cc
|
| @@ -69,12 +69,9 @@
|
| int HttpChunkedDecoder::FilterBuf(char* buf, int buf_len) {
|
| int result = 0;
|
|
|
| - while (buf_len > 0) {
|
| - if (chunk_remaining_ > 0) {
|
| - // Since |chunk_remaining_| is positive and |buf_len| an int, the minimum
|
| - // of the two must be an int.
|
| - int num = static_cast<int>(
|
| - std::min(chunk_remaining_, static_cast<int64_t>(buf_len)));
|
| + while (buf_len) {
|
| + if (chunk_remaining_) {
|
| + int num = std::min(chunk_remaining_, buf_len);
|
|
|
| buf_len -= num;
|
| chunk_remaining_ -= num;
|
| @@ -82,8 +79,8 @@
|
| result += num;
|
| buf += num;
|
|
|
| - // After each chunk's data there should be a CRLF.
|
| - if (chunk_remaining_ == 0)
|
| + // After each chunk's data there should be a CRLF
|
| + if (!chunk_remaining_)
|
| chunk_terminator_remaining_ = true;
|
| continue;
|
| } else if (reached_eof_) {
|
| @@ -96,7 +93,7 @@
|
| return bytes_consumed; // Error
|
|
|
| buf_len -= bytes_consumed;
|
| - if (buf_len > 0)
|
| + if (buf_len)
|
| memmove(buf, buf + bytes_consumed, buf_len);
|
| }
|
|
|
| @@ -124,17 +121,17 @@
|
| }
|
|
|
| if (reached_last_chunk_) {
|
| - if (buf_len > 0)
|
| + if (buf_len)
|
| DVLOG(1) << "ignoring http trailer";
|
| else
|
| reached_eof_ = true;
|
| } else if (chunk_terminator_remaining_) {
|
| - if (buf_len > 0) {
|
| + if (buf_len) {
|
| DLOG(ERROR) << "chunk data not terminated properly";
|
| return ERR_INVALID_CHUNKED_ENCODING;
|
| }
|
| chunk_terminator_remaining_ = false;
|
| - } else if (buf_len > 0) {
|
| + } else if (buf_len) {
|
| // Ignore any chunk-extensions.
|
| size_t index_of_semicolon = base::StringPiece(buf, buf_len).find(';');
|
| if (index_of_semicolon != base::StringPiece::npos)
|
| @@ -192,16 +189,14 @@
|
| // known sites.
|
| //
|
| // Us: ^\X+[ ]*$
|
| -bool HttpChunkedDecoder::ParseChunkSize(const char* start,
|
| - int len,
|
| - int64_t* out) {
|
| +bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) {
|
| DCHECK_GE(len, 0);
|
|
|
| // Strip trailing spaces
|
| - while (len > 0 && start[len - 1] == ' ')
|
| + while (len && start[len - 1] == ' ')
|
| len--;
|
|
|
| - // Be more restrictive than HexStringToInt64;
|
| + // Be more restrictive than HexStringToInt;
|
| // don't allow inputs with leading "-", "+", "0x", "0X"
|
| base::StringPiece chunk_size(start, len);
|
| if (chunk_size.find_first_not_of("0123456789abcdefABCDEF")
|
| @@ -209,8 +204,8 @@
|
| return false;
|
| }
|
|
|
| - int64_t parsed_number;
|
| - bool ok = base::HexStringToInt64(chunk_size, &parsed_number);
|
| + int parsed_number;
|
| + bool ok = base::HexStringToInt(chunk_size, &parsed_number);
|
| if (ok && parsed_number >= 0) {
|
| *out = parsed_number;
|
| return true;
|
|
|