diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 23:22:33 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 23:22:33 +0000 |
commit | 5368d6fd2781f457d25b16e59c13bd6b70baed93 (patch) | |
tree | 5f516c667ed9eeb69fb3e7aef12bbc051fcc1cc1 /net/http/http_chunked_decoder.cc | |
parent | 2ef7e2abebd1d702ff22cac67a0dd7f2660fd875 (diff) | |
download | chromium_src-5368d6fd2781f457d25b16e59c13bd6b70baed93.zip chromium_src-5368d6fd2781f457d25b16e59c13bd6b70baed93.tar.gz chromium_src-5368d6fd2781f457d25b16e59c13bd6b70baed93.tar.bz2 |
Refactor so checking for number error is done by ParseChunkSize() rather than the caller of ParseChunkSize().
Review URL: http://codereview.chromium.org/132037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_chunked_decoder.cc')
-rw-r--r-- | net/http/http_chunked_decoder.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/http/http_chunked_decoder.cc b/net/http/http_chunked_decoder.cc index 6ecdcad..71f7554 100644 --- a/net/http/http_chunked_decoder.cc +++ b/net/http/http_chunked_decoder.cc @@ -125,8 +125,7 @@ int HttpChunkedDecoder::ScanForChunkRemaining(const char* buf, int buf_len) { if (index_of_semicolon != StringPiece::npos) buf_len = static_cast<int>(index_of_semicolon); - if (!ParseChunkSize(buf, buf_len, &chunk_remaining_) || - chunk_remaining_ < 0) { + if (!ParseChunkSize(buf, buf_len, &chunk_remaining_)) { DLOG(ERROR) << "Failed parsing HEX from: " << std::string(buf, buf_len); return ERR_INVALID_CHUNKED_ENCODING; @@ -185,7 +184,14 @@ bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) { if (StringPiece(start, len).find_first_not_of("0123456789abcdefABCDEF")!= StringPiece::npos) return false; - return HexStringToInt(std::string(start, len), out); + + int parsed_number; + bool ok = HexStringToInt(std::string(start, len), &parsed_number); + if (ok && parsed_number >= 0) { + *out = parsed_number; + return true; + } + return false; } } // namespace net |