158776 r=cavin sr=bienvenu a=asa fixing nsCRT::strtok uses in pop3 protocol code.

This commit is contained in:
naving%netscape.com 2002-07-24 01:50:57 +00:00
Родитель d4bcf5a798
Коммит 2921fe9e65
1 изменённых файлов: 100 добавлений и 85 удалений

Просмотреть файл

@ -1175,13 +1175,17 @@ nsPop3Protocol::GetStat()
*/ */
oldStr = ToNewCString(m_commandResponse); oldStr = ToNewCString(m_commandResponse);
num = nsCRT::strtok(oldStr, " ", &newStr); num = nsCRT::strtok(oldStr, " ", &newStr);
if (num)
{
m_pop3ConData->number_of_messages = atol(num); m_pop3ConData->number_of_messages = atol(num);
num = nsCRT::strtok(newStr, " ", &newStr); num = nsCRT::strtok(newStr, " ", &newStr);
m_commandResponse = newStr; m_commandResponse = newStr;
if (num)
m_totalFolderSize = (PRInt32) atol(num); //we always initialize m_totalFolderSize to 0
}
else
m_pop3ConData->number_of_messages = 0;
m_totalFolderSize = (PRInt32) atol(num);
PR_FREEIF(oldStr); PR_FREEIF(oldStr);
m_pop3ConData->really_new_messages = 0; m_pop3ConData->really_new_messages = 0;
m_pop3ConData->real_new_counter = 1; m_pop3ConData->real_new_counter = 1;
@ -1290,7 +1294,7 @@ PRInt32
nsPop3Protocol::GetList(nsIInputStream* inputStream, nsPop3Protocol::GetList(nsIInputStream* inputStream,
PRUint32 length) PRUint32 length)
{ {
char * line, *token, *newStr; char * line;
PRUint32 ln = 0; PRUint32 ln = 0;
PRInt32 msg_num; PRInt32 msg_num;
@ -1328,6 +1332,7 @@ nsPop3Protocol::GetList(nsIInputStream* inputStream,
return(0); return(0);
} }
char *token, *newStr;
token = nsCRT::strtok(line, " ", &newStr); token = nsCRT::strtok(line, " ", &newStr);
if (token) if (token)
{ {
@ -1590,7 +1595,7 @@ PRInt32
nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream, nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
PRUint32 length) PRUint32 length)
{ {
char * line, *newStr; char * line;
PRUint32 ln = 0; PRUint32 ln = 0;
PRInt32 msg_num; PRInt32 msg_num;
@ -1641,9 +1646,13 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
return(0); return(0);
} }
msg_num = atol(nsCRT::strtok(line, " ", &newStr)); char *newStr;
char *token = nsCRT::strtok(line, " ", &newStr);
if(msg_num <= m_pop3ConData->number_of_messages && msg_num > 0) { if (token)
{
msg_num = atol(token);
if(msg_num <= m_pop3ConData->number_of_messages && msg_num > 0)
{
/* char *eatMessageIdToken = nsCRT::strtok(newStr, " ", &newStr); */ /* char *eatMessageIdToken = nsCRT::strtok(newStr, " ", &newStr); */
char *uidl = nsCRT::strtok(newStr, " ", &newStr);/* not really a uidl but a unique token -km */ char *uidl = nsCRT::strtok(newStr, " ", &newStr);/* not really a uidl but a unique token -km */
@ -1661,6 +1670,7 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
return MK_OUT_OF_MEMORY; return MK_OUT_OF_MEMORY;
} }
} }
}
PR_FREEIF(line); PR_FREEIF(line);
return(0); return(0);
@ -1684,7 +1694,7 @@ PRInt32 nsPop3Protocol::SendUidlList()
PRInt32 nsPop3Protocol::GetUidlList(nsIInputStream* inputStream, PRInt32 nsPop3Protocol::GetUidlList(nsIInputStream* inputStream,
PRUint32 length) PRUint32 length)
{ {
char * line, *newStr; char * line;
PRUint32 ln; PRUint32 ln;
PRInt32 msg_num; PRInt32 msg_num;
@ -1736,8 +1746,11 @@ PRInt32 nsPop3Protocol::GetUidlList(nsIInputStream* inputStream,
return(0); return(0);
} }
msg_num = atol(nsCRT::strtok(line, " ", &newStr)); char *newStr;
char *token = nsCRT::strtok(line, " ", &newStr);
if (token)
{
msg_num = atol(token);
if(msg_num <= m_pop3ConData->number_of_messages && msg_num > 0) if(msg_num <= m_pop3ConData->number_of_messages && msg_num > 0)
{ {
char *uidl = nsCRT::strtok(newStr, " ", &newStr); char *uidl = nsCRT::strtok(newStr, " ", &newStr);
@ -1756,6 +1769,7 @@ PRInt32 nsPop3Protocol::GetUidlList(nsIInputStream* inputStream,
return MK_OUT_OF_MEMORY; return MK_OUT_OF_MEMORY;
} }
} }
}
PR_FREEIF(line); PR_FREEIF(line);
return(0); return(0);
} }
@ -2173,7 +2187,6 @@ nsPop3Protocol::RetrResponse(nsIInputStream* inputStream,
PRUint32 buffer_size; PRUint32 buffer_size;
PRInt32 flags = 0; PRInt32 flags = 0;
char *uidl = NULL; char *uidl = NULL;
char *newStr;
nsresult rv; nsresult rv;
#if 0 #if 0
PRInt32 old_bytes_received = m_totalBytesReceived; PRInt32 old_bytes_received = m_totalBytesReceived;
@ -2198,9 +2211,11 @@ nsPop3Protocol::RetrResponse(nsIInputStream* inputStream,
} }
else else
{ {
char *newStr;
char * oldStr = ToNewCString(m_commandResponse); char * oldStr = ToNewCString(m_commandResponse);
m_pop3ConData->cur_msg_size = char *num = nsCRT::strtok(oldStr, " ", &newStr);
atol(nsCRT::strtok(oldStr, " ", &newStr)); if (num)
m_pop3ConData->cur_msg_size = atol(num);
m_commandResponse = newStr; m_commandResponse = newStr;
PR_FREEIF(oldStr); PR_FREEIF(oldStr);
} }