зеркало из https://github.com/mozilla/gecko-dev.git
fix crash downloading news article with extremely long line length, fix by bns_robson@hotmail.com, r=bienvenu,sr=sspitzer 87312
This commit is contained in:
Родитель
98a3075c9b
Коммит
7b28263ee1
|
@ -2546,7 +2546,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
|||
{
|
||||
char *line;
|
||||
PRUint32 status = 0;
|
||||
char outputBuffer[OUTPUT_BUFFER_SIZE];
|
||||
char *outputBuffer;
|
||||
|
||||
PRBool pauseForMoreData = PR_FALSE;
|
||||
|
||||
|
@ -2602,16 +2602,30 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
|||
if (m_tempArticleStream)
|
||||
m_tempArticleStream->Close();
|
||||
|
||||
// now mark the message as read
|
||||
MarkCurrentMsgRead();
|
||||
ClearFlag(NNTP_PAUSE_FOR_READ);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (line[0] == '.')
|
||||
PL_strcpy (outputBuffer, line + 1);
|
||||
outputBuffer = line + 1;
|
||||
else
|
||||
PL_strcpy (outputBuffer, line);
|
||||
outputBuffer = line;
|
||||
|
||||
/* Don't send content-type to mime parser if we're doing a cancel
|
||||
because it confuses mime parser into not parsing.
|
||||
*/
|
||||
if (m_typeWanted != CANCEL_WANTED || nsCRT::strncmp(outputBuffer, "Content-Type:", 13))
|
||||
{
|
||||
// if we are attempting to cancel, we want to snarf the headers and save the aside, which is what
|
||||
// ParseHeaderForCancel() does.
|
||||
if (m_typeWanted == CANCEL_WANTED) {
|
||||
ParseHeaderForCancel(outputBuffer);
|
||||
}
|
||||
|
||||
if (m_tempArticleStream)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
m_tempArticleStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
|
||||
/* When we're sending this line to a converter (ie,
|
||||
it's a message/rfc822) use the local line termination
|
||||
|
@ -2628,25 +2642,11 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
|||
PRBool canonicalLineEnding = PR_FALSE;
|
||||
if (msgurl)
|
||||
msgurl->GetCanonicalLineEnding(&canonicalLineEnding);
|
||||
if (canonicalLineEnding)
|
||||
PL_strcat(outputBuffer, CRLF);
|
||||
else
|
||||
PL_strcat (outputBuffer, MSG_LINEBREAK);
|
||||
/* Don't send content-type to mime parser if we're doing a cancel
|
||||
because it confuses mime parser into not parsing.
|
||||
*/
|
||||
if (m_typeWanted != CANCEL_WANTED || nsCRT::strncmp(outputBuffer, "Content-Type:", 13))
|
||||
{
|
||||
// if we are attempting to cancel, we want to snarf the headers and save the aside, which is what
|
||||
// ParseHeaderForCancel() does.
|
||||
if (m_typeWanted == CANCEL_WANTED) {
|
||||
ParseHeaderForCancel(outputBuffer);
|
||||
}
|
||||
|
||||
if (m_tempArticleStream)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
m_tempArticleStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
if (canonicalLineEnding)
|
||||
m_tempArticleStream->Write(CRLF, PL_strlen(CRLF), &count);
|
||||
else
|
||||
m_tempArticleStream->Write(MSG_LINEBREAK, PL_strlen(MSG_LINEBREAK), &count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче