--- a/mailnews/addrbook/src/nsAbLDIFService.cpp
+++ b/mailnews/addrbook/src/nsAbLDIFService.cpp
@@ -70,17 +70,17 @@ NS_IMETHODIMP nsAbLDIFService::ImportLDI
char buf[1024];
char* pBuf = &buf[0];
PRInt32 startPos = 0;
PRUint32 len = 0;
nsVoidArray listPosArray; // where each list/group starts in ldif file
nsVoidArray listSizeArray; // size of the list/group info
PRInt32 savedStartPos = 0;
PRInt32 filePos = 0;
- PRUint32 bytesLeft = 0;
+ PRUint64 bytesLeft = 0;
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
NS_ENSURE_SUCCESS(rv, rv);
// Initialize the parser for a run...
mLdifLine.Truncate();
--- a/mailnews/base/search/src/nsMsgFilterList.cpp
+++ b/mailnews/base/search/src/nsMsgFilterList.cpp
@@ -378,17 +378,17 @@ static const unsigned int sNumFilterFile
// If we want to buffer file IO, wrap it in here.
char nsMsgFilterList::ReadChar(nsIInputStream *aStream)
{
char newChar;
PRUint32 bytesRead;
nsresult rv = aStream->Read(&newChar, 1, &bytesRead);
if (NS_FAILED(rv) || !bytesRead)
return -1;
- PRUint32 bytesAvailable;
+ PRUint64 bytesAvailable;
rv = aStream->Available(&bytesAvailable);
if (NS_FAILED(rv))
return -1;
else
{
if (m_startWritingToBuffer)
m_unparsedFilterBuffer.Append(newChar);
return newChar;
@@ -491,17 +491,17 @@ nsresult nsMsgFilterList::LoadValue(nsCS
}
while (curChar != -1);
return NS_OK;
}
nsresult nsMsgFilterList::LoadTextFilters(nsIInputStream *aStream)
{
nsresult err = NS_OK;
- PRUint32 bytesAvailable;
+ PRUint64 bytesAvailable;
nsCOMPtr<nsIInputStream> bufStream;
err = NS_NewBufferedInputStream(getter_AddRefs(bufStream), aStream, 10240);
NS_ENSURE_SUCCESS(err, err);
nsMsgFilterFileAttribValue attrib;
nsCOMPtr<nsIMsgRuleAction> currentFilterAction;
// We'd really like to move lot's of these into the objects that they refer to.
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -1898,23 +1898,24 @@ nsSaveMsgListener::OnDataAvailable(nsIRe
return request->Cancel(NS_BINDING_ABORTED);
if (!mInitialized)
InitializeDownload(request, count);
if (m_dataBuffer && m_outputStream)
{
mProgress += count;
- PRUint32 available, readCount, maxReadCount = FOUR_K;
+ PRUint64 available;
+ PRUint32 readCount, maxReadCount = FOUR_K;
PRUint32 writeCount;
rv = inStream->Available(&available);
while (NS_SUCCEEDED(rv) && available)
{
if (maxReadCount > available)
- maxReadCount = available;
+ maxReadCount = (PRUint32)available;
rv = inStream->Read(m_dataBuffer, maxReadCount, &readCount);
// rhp:
// Ok, now we do one of two things. If we are sending out HTML, then
// just write it to the HTML stream as it comes along...but if this is
// a save as TEXT operation, we need to buffer this up for conversion
// when we are done. When the stream converter for HTML-TEXT gets in place,
// this magic can go away.
--- a/mailnews/base/util/nsMsgCompressIStream.cpp
+++ b/mailnews/base/util/nsMsgCompressIStream.cpp
@@ -115,18 +115,18 @@ NS_IMETHODIMP nsMsgCompressIStream::Clos
m_zbuf = nullptr;
m_databuf = nullptr;
m_dataptr = nullptr;
m_dataleft = 0;
return rv;
}
-/* unsigned long available (); */
-NS_IMETHODIMP nsMsgCompressIStream::Available(PRUint32 *aResult)
+/* unsigned long long available (); */
+NS_IMETHODIMP nsMsgCompressIStream::Available(PRUint64 *aResult)
{
if (!m_iStream)
return NS_BASE_STREAM_CLOSED;
// check if there's anything still in flight
if (!m_dataleft && m_inflateAgain)
{
nsresult rv = DoInflation();
--- a/mailnews/base/util/nsMsgFileStream.cpp
+++ b/mailnews/base/util/nsMsgFileStream.cpp
@@ -96,23 +96,23 @@ NS_IMETHODIMP nsMsgFileStream::Close()
{
nsresult rv = NS_OK;
if (mFileDesc && (PR_Close(mFileDesc) == PR_FAILURE))
rv = NS_BASE_STREAM_OSERROR;
mFileDesc = nullptr;
return rv;
}
-/* unsigned long available (); */
-NS_IMETHODIMP nsMsgFileStream::Available(PRUint32 *aResult)
+/* unsigned long long available (); */
+NS_IMETHODIMP nsMsgFileStream::Available(PRUint64 *aResult)
{
if (!mFileDesc)
return NS_BASE_STREAM_CLOSED;
- PRInt32 avail = PR_Available(mFileDesc);
+ PRInt64 avail = PR_Available64(mFileDesc);
if (avail == -1)
return ErrorAccordingToNSPR();
*aResult = avail;
return NS_OK;
}
/* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
--- a/mailnews/base/util/nsMsgFileStream.h
+++ b/mailnews/base/util/nsMsgFileStream.h
@@ -11,17 +11,17 @@
class nsMsgFileStream : public nsIInputStream, public nsIOutputStream, public nsISeekableStream
{
public:
nsMsgFileStream();
~nsMsgFileStream();
NS_DECL_ISUPPORTS
- NS_IMETHOD Available(PRUint32 *_retval);
+ NS_IMETHOD Available(PRUint64 *_retval);
NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval);
NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval);
NS_DECL_NSIOUTPUTSTREAM
NS_DECL_NSISEEKABLESTREAM
nsresult InitWithFile(nsIFile *localFile);
protected:
PRFileDesc *mFileDesc;
--- a/mailnews/base/util/nsMsgLineBuffer.cpp
+++ b/mailnews/base/util/nsMsgLineBuffer.cpp
@@ -3,17 +3,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "msgCore.h"
#include "prlog.h"
#include "prmem.h"
#include "nsMsgLineBuffer.h"
#include "nsAlgorithm.h"
-
+#include "nsMsgUtils.h"
#include "nsIInputStream.h" // used by nsMsgLineStreamBuffer
nsByteArray::nsByteArray()
{
MOZ_COUNT_CTOR(nsByteArray);
m_buffer = NULL;
m_bufferSize = 0;
m_bufferPos = 0;
@@ -312,17 +312,17 @@ char * nsMsgLineStreamBuffer::ReadNextLi
if (m_numBytesInBuffer > 0) // any data in our internal buffer?
endOfLine = PL_strchr(startOfLine, m_lineToken); // see if we already have a line ending...
// it's possible that we got here before the first time we receive data from the server
// so aInputStream will be nullptr...
if (!endOfLine && aInputStream) // get some more data from the server
{
nsresult rv;
- PRUint32 numBytesInStream = 0;
+ PRUint64 numBytesInStream = 0;
PRUint32 numBytesCopied = 0;
bool nonBlockingStream;
aInputStream->IsNonBlocking(&nonBlockingStream);
rv = aInputStream->Available(&numBytesInStream);
if (NS_FAILED(rv))
{
if (prv)
*prv = rv;
@@ -346,17 +346,20 @@ char * nsMsgLineStreamBuffer::ReadNextLi
m_startPos = 0;
startOfLine = m_dataBuffer;
numFreeBytesInBuffer = m_dataBufferSize - m_numBytesInBuffer;
//printf("moving data in read line around because buffer filling up\n");
}
// If we didn't make enough space (or any), grow the buffer
if (numBytesInStream >= numFreeBytesInBuffer)
{
- PRInt32 growBy = (numBytesInStream - numFreeBytesInBuffer) * 2 + 1;
+ PRInt64 growBy = (numBytesInStream - numFreeBytesInBuffer) * 2 + 1;
+ // GrowBuffer cannot handles over 4GB size
+ if (m_dataBufferSize + growBy > PR_UINT32_MAX)
+ return nullptr;
// try growing buffer by twice as much as we need.
nsresult rv = GrowBuffer(m_dataBufferSize + growBy);
// if we can't grow the buffer, we have to bail.
if (NS_FAILED(rv))
return nullptr;
startOfLine = m_dataBuffer;
numFreeBytesInBuffer += growBy;
}
--- a/mailnews/base/util/nsMsgMailNewsUrl.cpp
+++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp
@@ -819,17 +819,17 @@ nsMsgSaveAsListener::OnStopRequest(nsIRe
NS_IMETHODIMP nsMsgSaveAsListener::OnDataAvailable(nsIRequest* request,
nsISupports* aSupport,
nsIInputStream* inStream,
PRUint32 srcOffset,
PRUint32 count)
{
nsresult rv;
- PRUint32 available;
+ PRUint64 available;
rv = inStream->Available(&available);
if (!m_writtenData)
{
m_writtenData = true;
rv = SetupMsgWriteStream(m_outputFile, m_addDummyEnvelope);
NS_ENSURE_SUCCESS(rv, rv);
}
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -1036,17 +1036,17 @@ public:
//
// nsIOutputStreamCallback implementation ...
//
NS_IMETHODIMP OnOutputStreamReady(nsIAsyncOutputStream *aOutStream)
{
NS_ASSERTION(mInStream, "not initialized");
nsresult rv;
- PRUint32 avail;
+ PRUint64 avail;
// Write whatever is available in the pipe. If the pipe is empty, then
// return NS_BASE_STREAM_WOULD_BLOCK; we will resume the write when there
// is more data.
rv = mInStream->Available(&avail);
if (NS_FAILED(rv)) return rv;
@@ -1063,17 +1063,17 @@ public:
return NS_OK;
}
protInst->mSuspendedWrite = false;
PRUint32 bytesWritten;
if (avail)
{
- rv = aOutStream->WriteFrom(mInStream, NS_MIN(avail, 4096U), &bytesWritten);
+ rv = aOutStream->WriteFrom(mInStream, NS_MIN(avail, 4096), &bytesWritten);
// if were full at the time, the input stream may be backed up and we need to read any remains from the last ODA call
// before we'll get more ODA calls
if (protInst->mSuspendedRead)
protInst->UnblockPostReader();
}
else
{
rv = aOutStream->Write(protInst->mAsyncBuffer.get(),
@@ -1385,17 +1385,17 @@ nsresult nsMsgAsyncWriteProtocol::Unbloc
if (!m_socketIsOpen) return NS_OK; // kick out if the socket was canceled
if (mSuspendedRead)
{
// (1) attempt to write out any remaining read bytes we need in order to unblock the reader
if (mSuspendedReadBytes > 0 && mPostDataStream)
{
- PRUint32 avail = 0;
+ PRUint64 avail = 0;
mPostDataStream->Available(&avail);
m_outputStream->WriteFrom(mPostDataStream, NS_MIN(avail, mSuspendedReadBytes), &amountWritten);
// hmm sometimes my mSuspendedReadBytes is getting out of whack...so for now, reset it
// if necessary.
if (mSuspendedReadBytes > avail)
mSuspendedReadBytes = avail;
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -290,16 +290,26 @@ NS_MSG_BASE nsresult MsgDetectCharsetFro
* need that as an argument to the function. If charset is
* unknown or deemed of no importance NULL could be passed.
* @param[in/out] aConBuf Variable with the text to convert
* @param formatFlowed Use format flowed?
* @param formatOutput Reformat the output?
*/
NS_MSG_BASE nsresult ConvertBufToPlainText(nsString &aConBuf, bool formatFlowed, bool formatOutput);
+inline uint32_t NS_MIN(uint32_t a, uint64_t b)
+{
+ return b < a ? (uint32_t)b : a;
+}
+
+inline uint32_t NS_MIN(uint64_t a, uint32_t b)
+{
+ return b < a ? b : (uint32_t)a;
+}
+
/**
* The following definitons exist for compatibility between the internal and
* external APIs. Where possible they just forward to the existing API.
*/
#ifdef MOZILLA_INTERNAL_API
#include "nsEscape.h"
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -1016,31 +1016,32 @@ nsMsgTemplateReplyHelper::OnDataAvailabl
nsIInputStream* inStream,
PRUint32 srcOffset,
PRUint32 count)
{
nsresult rv = NS_OK;
char readBuf[1024];
- PRUint32 available, readCount;
+ PRUint64 available;
+ PRUint32 readCount;
PRUint32 maxReadCount = sizeof(readBuf) - 1;
rv = inStream->Available(&available);
while (NS_SUCCEEDED(rv) && available > 0)
{
PRUint32 bodyOffset = 0, readOffset = 0;
if (!mInMsgBody && mLastBlockChars[0])
{
memcpy(readBuf, mLastBlockChars, 3);
readOffset = 3;
maxReadCount -= 3;
}
if (maxReadCount > available)
- maxReadCount = available;
+ maxReadCount = (PRUint32)available;
memset(readBuf, 0, sizeof(readBuf));
rv = inStream->Read(readBuf + readOffset, maxReadCount, &readCount);
available -= readCount;
readCount += readOffset;
// we're mainly interested in the msg body, so we need to
// find the header/body delimiter of a blank line. A blank line
// looks like <CR><CR>, <LF><LF>, or <CRLF><CRLF>
if (!mInMsgBody)
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -4798,17 +4798,17 @@ nsMsgComposeAndSend::MimeDoFCC(nsIFile
// There are two tricky parts: the first is that the message file
// uses CRLF, and the FCC file should use LINEBREAK. The second
// is that the message file may have lines beginning with "From "
// but the FCC file must have those lines mangled.
//
// It's unfortunate that we end up writing the FCC file a line
// at a time, but it's the easiest way...
//
- PRUint32 available;
+ PRUint64 available;
rv = inputFile->Available(&available);
NS_ENSURE_SUCCESS(rv, rv);
while (available > 0)
{
// check *ibuffer in case that ibuffer isn't big enough
PRUint32 readCount;
rv = inputFile->Read(ibuffer, ibuffer_size, &readCount);
if (NS_FAILED(rv) || readCount == 0 || *ibuffer == 0)
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -9205,17 +9205,17 @@ NS_IMETHODIMP nsImapMailFolder::FetchMsg
rv = msgService->IsMsgInMemCache(url, this, getter_AddRefs(cacheEntry), &msgInMemCache);
NS_ENSURE_SUCCESS(rv, rv);
if (msgInMemCache)
{
rv = cacheEntry->OpenInputStream(0, getter_AddRefs(inputStream));
if (NS_SUCCEEDED(rv))
{
- PRUint32 bytesAvailable = 0;
+ PRUint64 bytesAvailable = 0;
rv = inputStream->Available(&bytesAvailable);
if (!bytesAvailable)
continue;
rv = GetMsgPreviewTextFromStream(msgHdr, inputStream);
}
}
else // lets look in the offline store
{
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -1099,17 +1099,17 @@ NS_IMETHODIMP nsImapProtocol::GetUrlWind
return aUrl->GetMsgWindow(aMsgWindow);
}
NS_IMETHODIMP nsImapProtocol::OnInputStreamReady(nsIAsyncInputStream *inStr)
{
// should we check if it's a close vs. data available?
if (m_idle)
{
- PRUint32 bytesAvailable = 0;
+ PRUint64 bytesAvailable = 0;
(void) inStr->Available(&bytesAvailable);
// check if data available - might be a close
if (bytesAvailable != 0)
{
ReentrantMonitorAutoEnter mon(m_urlReadyToRunMonitor);
m_lastActiveTime = PR_Now();
m_nextUrlReadyToRun = true;
mon.Notify();
@@ -9036,17 +9036,17 @@ nsresult nsImapMockChannel::ReadFromMemC
in->Close();
}
if (shouldUseCacheEntry)
{
nsCOMPtr<nsIInputStream> in;
rv = entry->OpenInputStream(0, getter_AddRefs(in));
NS_ENSURE_SUCCESS(rv, rv);
// if mem cache entry is broken or empty, return error.
- PRUint32 bytesAvailable;
+ PRUint64 bytesAvailable;
rv = in->Available(&bytesAvailable);
NS_ENSURE_SUCCESS(rv, rv);
if (!bytesAvailable)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump), in);
NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -93,17 +93,17 @@ nsresult nsEudoraAddress::ImportAddresse
EmptyAliases();
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), pSrc);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error opening address file for reading\n");
return rv;
}
- PRUint32 bytesLeft = 0;
+ PRUint64 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error checking address file for eof\n");
inputStream->Close();
return rv;
}
--- a/mailnews/import/eudora/src/nsEudoraWin32.cpp
+++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp
@@ -189,25 +189,25 @@ nsresult nsEudoraWin32::ScanMailDir(nsIF
rv = descMap->Exists(&exists);
if (NS_SUCCEEDED(rv) && exists && isFile)
{
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), descMap);
if (NS_FAILED(rv))
return rv;
- PRUint32 bytesLeft = 0;
-
- rv = inputStream->Available(&bytesLeft);
+ PRUint64 bytesLeft64;
+ rv = inputStream->Available(&bytesLeft64);
if (NS_FAILED(rv))
{
IMPORT_LOG0("*** Error checking address file for eof\n");
inputStream->Close();
return rv;
}
+ PRUint32 bytesLeft = NS_MIN(PR_UINT32_MAX - 1, bytesLeft64);
pContents = (char *) PR_Malloc(bytesLeft + 1);
if (!pContents)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 bytesRead;
rv = inputStream->Read(pContents, bytesLeft, &bytesRead);
if (bytesRead != bytesLeft)
return NS_ERROR_FAILURE;
pContents[bytesRead] = '\0';
--- a/mailnews/import/src/nsImportScanFile.cpp
+++ b/mailnews/import/src/nsImportScanFile.cpp
@@ -56,17 +56,17 @@ void nsImportScanFile::ShiftBuffer(void)
}
m_bytesInBuf -= m_pos;
m_pos = 0;
}
bool nsImportScanFile::FillBufferFromFile(void)
{
- PRUint32 available;
+ PRUint64 available;
nsresult rv = m_pInputStream->Available(&available);
if (NS_FAILED(rv))
return false;
// Fill up a buffer and scan it
ShiftBuffer();
// Read in some more bytes
@@ -86,17 +86,17 @@ bool nsImportScanFile::FillBufferFromFil
m_eof = true;
m_bytesInBuf += cnt;
return true;
}
bool nsImportScanFile::Scan(bool *pDone)
{
- PRUint32 available;
+ PRUint64 available;
nsresult rv = m_pInputStream->Available(&available);
if (NS_FAILED(rv))
{
if (m_pos < m_bytesInBuf)
ScanBuffer(pDone);
*pDone = true;
return true;
}
--- a/mailnews/import/text/src/nsTextAddress.cpp
+++ b/mailnews/import/text/src/nsTextAddress.cpp
@@ -81,25 +81,25 @@ nsresult nsTextAddress::ImportAddresses(
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error opening address file for reading\n");
return rv;
}
// Here we use this to work out the size of the file, so we can update
// an integer as we go through the file which will update a progress
// bar if required by the caller.
- PRUint32 bytesLeft = 0;
+ PRUint64 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error checking address file for size\n");
inputStream->Close();
return rv;
}
- PRUint32 totalBytes = bytesLeft;
+ PRUint64 totalBytes = bytesLeft;
bool skipRecord = false;
rv = m_fieldMap->GetSkipFirstRecord(&skipRecord);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error checking to see if we should skip the first record\n");
return rv;
}
@@ -128,17 +128,17 @@ nsresult nsTextAddress::ImportAddresses(
IMPORT_LOG0("*** Error processing text record.\n");
}
}
if (NS_SUCCEEDED(rv) && pProgress) {
// This won't be totally accurate, but its the best we can do
// considering that lineStream won't give us how many bytes
// are actually left.
bytesLeft -= line.Length();
- *pProgress = totalBytes - bytesLeft;
+ *pProgress = NS_MIN(totalBytes - bytesLeft, PR_UINT32_MAX);
}
}
inputStream->Close();
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error reading the address book - probably incorrect ending\n");
return NS_ERROR_FAILURE;
@@ -187,17 +187,17 @@ nsresult nsTextAddress::ReadRecordNumber
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error opening address file for reading\n");
return rv;
}
PRInt32 rIndex = 0;
- PRUint32 bytesLeft = 0;
+ PRUint64 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error checking address file for eof\n");
inputStream->Close();
return rv;
}
--- a/mailnews/import/vcard/src/nsVCardAddress.cpp
+++ b/mailnews/import/vcard/src/nsVCardAddress.cpp
@@ -41,25 +41,25 @@ nsresult nsVCardAddress::ImportAddresses
IMPORT_LOG0("*** Error opening address file for reading\n");
return rv;
}
// Open the source file for reading, read each line and process it!
// Here we use this to work out the size of the file, so we can update
// an integer as we go through the file which will update a progress
// bar if required by the caller.
- PRUint32 bytesLeft = 0;
+ PRUint64 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error checking address file for size\n");
inputStream->Close();
return rv;
}
- PRUint32 totalBytes = bytesLeft;
+ PRUint64 totalBytes = bytesLeft;
nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAbManager> ab = do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
bool more = true;
nsCString record;
--- a/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.cpp
+++ b/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.cpp
@@ -443,17 +443,17 @@ nsPgpMimeProxy::SetLoadFlags(nsLoadFlags
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIInputStream methods
///////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
-nsPgpMimeProxy::Available(PRUint32* _retval)
+nsPgpMimeProxy::Available(PRUint64* _retval)
{
NS_ENSURE_ARG(_retval);
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
*_retval = (mByteBuf.Length() > mStreamOffset) ?
mByteBuf.Length() - mStreamOffset : 0;
--- a/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
@@ -483,20 +483,21 @@ nsMimeBaseEmitter::Write(const nsACStrin
nsresult
nsMimeBaseEmitter::WriteHelper(const char *buf, PRUint32 count, PRUint32 *countWritten)
{
NS_ENSURE_TRUE(mOutStream, NS_ERROR_NOT_INITIALIZED);
nsresult rv = mOutStream->Write(buf, count, countWritten);
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
// pipe is full, push contents of pipe to listener...
- PRUint32 avail;
+ PRUint64 avail;
rv = mInputStream->Available(&avail);
if (NS_SUCCEEDED(rv) && avail) {
- mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, avail);
+ mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0,
+ NS_MIN(avail, PR_UINT32_MAX));
// try writing again...
rv = mOutStream->Write(buf, count, countWritten);
}
}
return rv;
}
@@ -1045,23 +1046,23 @@ nsMimeBaseEmitter::Complete()
PRUint32 written;
nsresult rv = NS_OK;
while ( NS_SUCCEEDED(rv) && (mBufferMgr) && (mBufferMgr->GetSize() > 0))
rv = Write(EmptyCString(), &written);
if (mOutListener)
{
- PRUint32 bytesInStream = 0;
+ PRUint64 bytesInStream = 0;
nsresult rv2 = mInputStream->Available(&bytesInStream);
NS_ASSERTION(NS_SUCCEEDED(rv2), "Available failed");
if (bytesInStream)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(mChannel);
- rv2 = mOutListener->OnDataAvailable(request, mURL, mInputStream, 0, bytesInStream);
+ mOutListener->OnDataAvailable(request, mURL, mInputStream, 0, NS_MIN(bytesInStream, PR_UINT32_MAX));
}
}
return NS_OK;
}
//
// This needs to do the right thing with the stored information. It only
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -2122,39 +2122,39 @@ PRInt32 nsNNTPProtocol::DisplayArticle(n
bool pauseForMoreData = false;
if (m_channelListener)
{
nsresult rv = NS_OK;
char *line = m_lineStreamBuffer->ReadNextLine(inputStream, line_length, pauseForMoreData, &rv, true);
if (pauseForMoreData)
{
- PRUint32 inlength = 0;
+ PRUint64 inlength = 0;
mDisplayInputStream->Available(&inlength);
if (inlength > 0) // broadcast our batched up ODA changes
- m_channelListener->OnDataAvailable(this, m_channelContext, mDisplayInputStream, 0, inlength);
+ m_channelListener->OnDataAvailable(this, m_channelContext, mDisplayInputStream, 0, NS_MIN(inlength, PR_UINT32_MAX));
SetFlag(NNTP_PAUSE_FOR_READ);
PR_Free(line);
return line_length;
}
if (m_newsFolder)
m_newsFolder->NotifyDownloadedLine(line, m_key);
// line only contains a single dot -> message end
if (line_length == 1 + MSG_LINEBREAK_LEN && line[0] == '.')
{
m_nextState = NEWS_DONE;
ClearFlag(NNTP_PAUSE_FOR_READ);
- PRUint32 inlength = 0;
+ PRUint64 inlength = 0;
mDisplayInputStream->Available(&inlength);
if (inlength > 0) // broadcast our batched up ODA changes
- m_channelListener->OnDataAvailable(this, m_channelContext, mDisplayInputStream, 0, inlength);
+ m_channelListener->OnDataAvailable(this, m_channelContext, mDisplayInputStream, 0, NS_MIN(inlength, PR_UINT32_MAX));
PR_Free(line);
return line_length;
}
else // we aren't finished with the message yet
{
PRUint32 count = 0;
// skip over the quoted '.'