Bug 790617 - Part 2 - don't use atoi to parse header. r=cbiesinger
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1575,17 +1575,17 @@ HttpBaseChannel::SetupReplacementChannel
const char *clen =
mRequestHead.PeekHeader(nsHttp::Content_Length);
if (!ctype) {
ctype = "application/octet-stream";
}
if (clen) {
uploadChannel->SetUploadStream(mUploadStream,
nsDependentCString(ctype),
- atoi(clen));
+ nsCRT::atoll(clen));
}
}
}
}
// since preserveMethod is true, we need to ensure that the appropriate
// request method gets set on the channel, regardless of whether or not
// we set the upload stream above. This means SetRequestMethod() will
// be called twice if ExplicitSetUploadStream() gets called above.
--- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp
+++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp
@@ -949,17 +949,17 @@ nsMultiMixedConv::ParseHeaders(nsIChanne
nsAutoCString headerVal(colon + 1);
headerVal.CompressWhitespace();
// examine header
if (headerStr.LowerCaseEqualsLiteral("content-type")) {
mContentType = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("content-length")) {
- mContentLength = atoi(headerVal.get()); // XXX 64-bit math?
+ mContentLength = nsCRT::atoll(headerVal.get());
} else if (headerStr.LowerCaseEqualsLiteral("content-disposition")) {
mContentDisposition = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("set-cookie")) {
nsCOMPtr<nsIHttpChannelInternal> httpInternal =
do_QueryInterface(aChannel);
if (httpInternal) {
httpInternal->SetCookie(headerVal.get());
}
@@ -983,24 +983,24 @@ nsMultiMixedConv::ParseHeaders(nsIChanne
}
else {
tmpPtr = (char *) strchr(range, '-');
if (!tmpPtr)
return NS_ERROR_FAILURE;
tmpPtr[0] = '\0';
- mByteRangeStart = atoi(range); // XXX want 64-bit conv
+ mByteRangeStart = nsCRT::atoll(range);
tmpPtr++;
- mByteRangeEnd = atoi(tmpPtr);
+ mByteRangeEnd = nsCRT::atoll(tmpPtr);
}
mIsByteRangeRequest = true;
if (mContentLength == LL_MAXUINT)
- mContentLength = uint64_t(int64_t(mByteRangeEnd - mByteRangeStart + int64_t(1)));
+ mContentLength = uint64_t(mByteRangeEnd - mByteRangeStart + 1);
}
}
*newLine = tmpChar;
newLine += lineFeedIncrement;
cursorLen -= (newLine - cursor);
cursor = newLine;
}