diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-27 00:45:32 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-27 00:45:32 +0900 |
| commit | 89f18dde856894eef23dde77a9257655725ba843 (patch) | |
| tree | 73d5ea34e16655e524fd00b807d03450953061b6 /src/HttpHeader.cc | |
| parent | a879d75aaacce6c838b20c3c961b38182a1179b2 (diff) | |
Use nothrow version of parseInt, parseUInt and parseLLInt
Diffstat (limited to 'src/HttpHeader.cc')
| -rw-r--r-- | src/HttpHeader.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 40181bd3..d7a313e6 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -93,9 +93,10 @@ RangeHandle HttpHeader::getRange() const if(clenStr.empty()) { return SharedHandle<Range>(new Range()); } else { - int64_t contentLength = util::parseLLInt(clenStr); - if(contentLength < 0) { - throw DL_ABORT_EX("Content-Length must be positive"); + int64_t contentLength; + if(!util::parseLLIntNoThrow(contentLength, clenStr) || + contentLength < 0) { + throw DL_ABORT_EX("Content-Length must be positive integer"); } else if(contentLength > std::numeric_limits<off_t>::max()) { throw DOWNLOAD_FAILURE_EXCEPTION (fmt(EX_TOO_LARGE_FILE, contentLength)); @@ -135,11 +136,12 @@ RangeHandle HttpHeader::getRange() const if(minus == slash) { return SharedHandle<Range>(new Range()); } - int64_t startByte = util::parseLLInt(std::string(byteRangeSpec, minus)); - int64_t endByte = util::parseLLInt(std::string(minus+1, slash)); - int64_t entityLength = - util::parseLLInt(std::string(slash+1, rangeStr.end())); - if(startByte < 0 || endByte < 0 || entityLength < 0) { + int64_t startByte, endByte, entityLength; + if(!util::parseLLIntNoThrow(startByte, std::string(byteRangeSpec, minus)) || + !util::parseLLIntNoThrow(endByte, std::string(minus+1, slash)) || + !util::parseLLIntNoThrow(entityLength, + std::string(slash+1, rangeStr.end())) || + startByte < 0 || endByte < 0 || entityLength < 0) { throw DL_ABORT_EX("byte-range-spec must be positive"); } if(startByte > std::numeric_limits<off_t>::max()) { |
