fixed bug 21670 -- read mail crashes on particular message (HP-UX); r=mscott,a=chofmann

This commit is contained in:
jefft%netscape.com 1999-12-20 14:54:17 +00:00
parent c102d5ff19
commit 624d8a50ea
2 changed files with 21 additions and 13 deletions

View File

@ -1785,7 +1785,8 @@ NS_IMETHODIMP nsImapMailFolder::CopyData(nsIInputStream *aIStream,
&readCount);
if (NS_FAILED(rv)) return rv;
m_copyState->m_dataBuffer[readCount+m_copyState->m_leftOver] = '\0';
m_copyState->m_leftOver += readCount;
m_copyState->m_dataBuffer[m_copyState->m_leftOver] = '\0';
start = m_copyState->m_dataBuffer;
end = PL_strstr(start, "\r");
@ -1797,8 +1798,12 @@ NS_IMETHODIMP nsImapMailFolder::CopyData(nsIInputStream *aIStream,
if (linebreak_len == 0) // not initialize yet
linebreak_len = 1;
if (!end)
m_copyState->m_leftOver = PL_strlen(start);
aLength -= readCount;
maxReadCount = FOUR_K - m_copyState->m_leftOver;
if (!end && aLength > (PRInt32) maxReadCount)
// must be a very very long line; sorry cannot handle it
return NS_ERROR_FAILURE;
while (start && end)
{
@ -1813,7 +1818,7 @@ NS_IMETHODIMP nsImapMailFolder::CopyData(nsIInputStream *aIStream,
}
start = end+linebreak_len;
if (start >=
m_copyState->m_dataBuffer+readCount+m_copyState->m_leftOver)
m_copyState->m_dataBuffer+m_copyState->m_leftOver)
{
m_copyState->m_leftOver = 0;
break;
@ -1823,14 +1828,13 @@ NS_IMETHODIMP nsImapMailFolder::CopyData(nsIInputStream *aIStream,
end = PL_strstr(start, "\n");
if (start && !end)
{
m_copyState->m_leftOver = PL_strlen(start);
m_copyState->m_leftOver -= (start - m_copyState->m_dataBuffer);
nsCRT::memcpy(m_copyState->m_dataBuffer, start,
m_copyState->m_leftOver+1); // including null
maxReadCount = FOUR_K - m_copyState->m_leftOver;
}
}
if (NS_FAILED(rv)) return rv;
aLength -= readCount;
}
return rv;
}

View File

@ -1032,7 +1032,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetRememberedPassword(char ** password)
return NS_OK;
}
nsresult
nsMsgLocalMailFolder::GetTrashFolder(nsIMsgFolder** result)
{
@ -1542,7 +1541,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
rv = aIStream->Read(mCopyState->m_dataBuffer + mCopyState->m_leftOver,
maxReadCount, &readCount);
mCopyState->m_dataBuffer[readCount+mCopyState->m_leftOver] ='\0';
if (NS_FAILED(rv)) return rv;
mCopyState->m_leftOver += readCount;
mCopyState->m_dataBuffer[mCopyState->m_leftOver] ='\0';
start = mCopyState->m_dataBuffer;
end = PL_strstr(start, "\r");
@ -1554,8 +1555,12 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
if (linebreak_len == 0) // not set yet
linebreak_len = 1;
if (!end)
mCopyState->m_leftOver = PL_strlen(start);
aLength -= readCount;
maxReadCount = FOUR_K - mCopyState->m_leftOver;
if (!end && aLength > (PRInt32) maxReadCount)
// this must be a gigantic line with no linefeed; sorry pal cannot handle
return NS_ERROR_FAILURE;
while (start && end)
{
@ -1567,7 +1572,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
*(mCopyState->m_fileStream) << MSG_LINEBREAK;
start = end+linebreak_len;
if (start >=
&mCopyState->m_dataBuffer[readCount+mCopyState->m_leftOver])
&mCopyState->m_dataBuffer[mCopyState->m_leftOver])
{
mCopyState->m_leftOver = 0;
break;
@ -1577,13 +1582,12 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
end = PL_strstr(start, "\n");
if (start && !end)
{
mCopyState->m_leftOver = PL_strlen(start);
mCopyState->m_leftOver -= (start - mCopyState->m_dataBuffer);
nsCRT::memcpy (mCopyState->m_dataBuffer, start,
mCopyState->m_leftOver+1);
maxReadCount = FOUR_K - mCopyState->m_leftOver;
}
}
aLength -= readCount;
}
return rv;