mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
fix 234421 authentication error on login POP3 server patch by ch.ey@gmx.net r=bienvenu, sr=mscott
This commit is contained in:
parent
f9c2689dac
commit
ec8e88d353
@ -241,11 +241,10 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
|
||||
if (newline[-1] != nsCRT::CR && newline[-1] != nsCRT::LF)
|
||||
return -1;
|
||||
|
||||
if (!m_convertNewlinesP)
|
||||
if (m_convertNewlinesP)
|
||||
{
|
||||
}
|
||||
#if (MSG_LINEBREAK_LEN == 1)
|
||||
else if ((newline - buf) >= 2 &&
|
||||
if ((newline - buf) >= 2 &&
|
||||
newline[-2] == nsCRT::CR &&
|
||||
newline[-1] == nsCRT::LF)
|
||||
{
|
||||
@ -260,7 +259,7 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
|
||||
buf [length - 1] = MSG_LINEBREAK[0];
|
||||
}
|
||||
#else
|
||||
else if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
|
||||
if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
|
||||
((newline - buf) >= 1 && newline[-1] != nsCRT::LF))
|
||||
{
|
||||
/* LF -> CRLF or CR -> CRLF */
|
||||
@ -269,7 +268,7 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
|
||||
buf[length - 1] = MSG_LINEBREAK[1];
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
|
||||
}
|
||||
|
||||
@ -321,6 +320,12 @@ nsresult nsMsgLineStreamBuffer::GrowBuffer(PRInt32 desiredSize)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsMsgLineStreamBuffer::ClearBuffer()
|
||||
{
|
||||
m_startPos = 0;
|
||||
m_numBytesInBuffer = 0;
|
||||
}
|
||||
|
||||
// aInputStream - the input stream we want to read a line from
|
||||
// aPauseForMoreData is returned as PR_TRUE if the stream does not yet contain a line and we must wait for more
|
||||
// data to come into the stream.
|
||||
@ -371,18 +376,17 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
|
||||
PRUint32 numFreeBytesInBuffer = m_dataBufferSize - m_startPos - m_numBytesInBuffer;
|
||||
if (numBytesInStream >= numFreeBytesInBuffer)
|
||||
{
|
||||
if (m_numBytesInBuffer && m_startPos)
|
||||
if (m_startPos)
|
||||
{
|
||||
memmove(m_dataBuffer, startOfLine, m_numBytesInBuffer);
|
||||
m_dataBuffer[m_numBytesInBuffer] = '\0'; // make sure the end
|
||||
// of the buffer is
|
||||
// terminated
|
||||
// make sure the end of the buffer is terminated
|
||||
m_dataBuffer[m_numBytesInBuffer] = '\0';
|
||||
m_startPos = 0;
|
||||
startOfLine = m_dataBuffer;
|
||||
numFreeBytesInBuffer = m_dataBufferSize - m_numBytesInBuffer;
|
||||
// printf("moving data in read line around because buffer filling up\n");
|
||||
//printf("moving data in read line around because buffer filling up\n");
|
||||
}
|
||||
else if (!m_startPos)
|
||||
else
|
||||
{
|
||||
PRInt32 growBy = (numBytesInStream - numFreeBytesInBuffer) * 2 + 1;
|
||||
// try growing buffer by twice as much as we need.
|
||||
@ -397,33 +401,28 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
|
||||
}
|
||||
|
||||
PRUint32 numBytesToCopy = PR_MIN(numFreeBytesInBuffer - 1 /* leave one for a null terminator */, numBytesInStream);
|
||||
// read the data into the end of our data buffer
|
||||
if (numBytesToCopy > 0)
|
||||
{
|
||||
// read the data into the end of our data buffer
|
||||
rv = aInputStream->Read(startOfLine + m_numBytesInBuffer, numBytesToCopy,
|
||||
&numBytesCopied);
|
||||
if (prv)
|
||||
*prv = rv;
|
||||
PRUint32 i;
|
||||
PRUint32 endBufPos = m_numBytesInBuffer + numBytesCopied;
|
||||
for (i = m_numBytesInBuffer; i <endBufPos; i++) //replace nulls with spaces
|
||||
for (i = m_numBytesInBuffer; i < endBufPos; i++) // replace nulls with spaces
|
||||
{
|
||||
if (!startOfLine[i])
|
||||
startOfLine[i] = ' ';
|
||||
}
|
||||
m_numBytesInBuffer += numBytesCopied;
|
||||
m_dataBuffer[m_startPos + m_numBytesInBuffer] = '\0';
|
||||
}
|
||||
else if (!m_numBytesInBuffer)
|
||||
{
|
||||
aPauseForMoreData = PR_TRUE;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// okay, now that we've tried to read in more data from the stream, look for another end of line
|
||||
// character
|
||||
// okay, now that we've tried to read in more data from the stream,
|
||||
// look for another end of line character
|
||||
endOfLine = PL_strchr(startOfLine, m_lineToken);
|
||||
}
|
||||
}
|
||||
|
||||
// okay, now check again for endOfLine.
|
||||
if (endOfLine)
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
// aPauseForMoreData -- There is not enough data in the stream to make a line at this time...
|
||||
char * ReadNextLine(nsIInputStream * aInputStream, PRUint32 &anumBytesInLine, PRBool &aPauseForMoreData, nsresult *rv = nsnull);
|
||||
nsresult GrowBuffer(PRInt32 desiredSize);
|
||||
void ClearBuffer();
|
||||
PRBool NextLineAvailable();
|
||||
protected:
|
||||
PRBool m_eatCRLFs;
|
||||
|
@ -1068,6 +1068,11 @@ nsPop3Protocol::Error(PRInt32 err_code)
|
||||
|
||||
PRInt32 nsPop3Protocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
// remove any leftover bytes in the line buffer
|
||||
// this can happen if the last message line doesn't end with a (CR)LF
|
||||
// or a server sent two reply lines
|
||||
m_lineStreamBuffer->ClearBuffer();
|
||||
|
||||
PRInt32 result = nsMsgProtocol::SendData(aURL, dataBuffer);
|
||||
|
||||
if (!aSuppressLogging)
|
||||
@ -2265,8 +2270,8 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
|
||||
if(m_pop3ConData->msg_info[m_listpos - 1].msgnum == msg_num)
|
||||
i = m_listpos - 1;
|
||||
else
|
||||
for(i = 0; m_pop3ConData->msg_info[i].msgnum != msg_num &&
|
||||
i <= m_pop3ConData->number_of_messages; i++)
|
||||
for(i = 0; i < m_pop3ConData->number_of_messages &&
|
||||
m_pop3ConData->msg_info[i].msgnum != msg_num; i++)
|
||||
;
|
||||
|
||||
m_pop3ConData->msg_info[i].uidl = PL_strdup(uidl);
|
||||
@ -2377,8 +2382,8 @@ PRInt32 nsPop3Protocol::GetUidlList(nsIInputStream* inputStream,
|
||||
if(m_pop3ConData->msg_info[m_listpos - 1].msgnum == msg_num)
|
||||
i = m_listpos - 1;
|
||||
else
|
||||
for(i = 0; m_pop3ConData->msg_info[i].msgnum != msg_num &&
|
||||
i <= m_pop3ConData->number_of_messages; i++)
|
||||
for(i = 0; i < m_pop3ConData->number_of_messages &&
|
||||
m_pop3ConData->msg_info[i].msgnum != msg_num; i++)
|
||||
;
|
||||
|
||||
m_pop3ConData->msg_info[i].uidl = PL_strdup(uidl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user