Bug 1391128 - Use strtoul() instead of atoi() when converting UID to uint32_t. r=aceman

This commit is contained in:
Jorg K 2017-08-18 22:11:30 +02:00
Родитель 00190cd92d
Коммит ae672ccce0
4 изменённых файлов: 22 добавлений и 20 удалений

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

@ -2107,7 +2107,7 @@ bool nsImapProtocol::TryToRunUrlLocally(nsIURI *aURL, nsISupports *aConsumer)
mailnewsUrl->GetFolder(getter_AddRefs(folder));
NS_ENSURE_TRUE(folder, false);
folder->HasMsgOffline(atoi(messageIdString.get()), &useLocalCache);
folder->HasMsgOffline(strtoul(messageIdString.get(), nullptr, 10), &useLocalCache);
mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
// We're downloading a single message for offline use, and it's
// already offline. So we shouldn't do anything, but we do
@ -2704,7 +2704,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
foundShell->SetConnection(this);
GetServerStateParser().UseCachedShell(foundShell);
//Set the current uid in server state parser (in case it was used for new mail msgs earlier).
GetServerStateParser().SetCurrentResponseUID((uint32_t)atoi(messageIdString.get()));
GetServerStateParser().SetCurrentResponseUID(strtoul(messageIdString.get(), nullptr, 10));
foundShell->Generate(imappart);
GetServerStateParser().UseCachedShell(NULL);
}
@ -2776,7 +2776,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
foundShell->SetConnection(this);
GetServerStateParser().UseCachedShell(foundShell);
//Set the current uid in server state parser (in case it was used for new mail msgs earlier).
GetServerStateParser().SetCurrentResponseUID((uint32_t)atoi(messageIdString.get()));
GetServerStateParser().SetCurrentResponseUID(strtoul(messageIdString.get(), nullptr, 10));
foundShell->Generate(NULL);
GetServerStateParser().UseCachedShell(NULL);
}
@ -2798,7 +2798,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
&& m_imapAction != nsIImapUrl::nsImapMsgPreview
&& m_imapAction != nsIImapUrl::nsImapMsgFetchPeek)
{
uint32_t uid = atoi(messageIdString.get());
uint32_t uid = strtoul(messageIdString.get(), nullptr, 10);
int32_t index;
bool foundIt;
imapMessageFlagsType flags = m_flagState->GetMessageFlagsFromUID(uid, &foundIt, &index);

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

@ -561,7 +561,7 @@ void nsImapServerResponseParser::response_data()
AdvanceToNextToken();
if (fNextToken)
{
fStatusNextUID = atoi(fNextToken);
fStatusNextUID = strtoul(fNextToken, nullptr, 10);
// if this token ends in ')', then it is the last token
// else we advance
if ( *(fNextToken + strlen(fNextToken) - 1) == ')')
@ -573,7 +573,7 @@ void nsImapServerResponseParser::response_data()
AdvanceToNextToken();
if (fNextToken)
{
fStatusExistingMessages = atoi(fNextToken);
fStatusExistingMessages = strtoul(fNextToken, nullptr, 10);
// if this token ends in ')', then it is the last token
// else we advance
if ( *(fNextToken + strlen(fNextToken) - 1) == ')')
@ -585,7 +585,7 @@ void nsImapServerResponseParser::response_data()
AdvanceToNextToken();
if (fNextToken)
{
fStatusUnseenMessages = atoi(fNextToken);
fStatusUnseenMessages = strtoul(fNextToken, nullptr, 10);
// if this token ends in ')', then it is the last token
// else we advance
if ( *(fNextToken + strlen(fNextToken) - 1) == ')')
@ -597,7 +597,7 @@ void nsImapServerResponseParser::response_data()
AdvanceToNextToken();
if (fNextToken)
{
fStatusRecentMessages = atoi(fNextToken);
fStatusRecentMessages = strtoul(fNextToken, nullptr, 10);
// if this token ends in ')', then it is the last token
// else we advance
if ( *(fNextToken + strlen(fNextToken) - 1) == ')')
@ -1070,7 +1070,7 @@ void nsImapServerResponseParser::msg_fetch()
AdvanceToNextToken();
if (ContinueParse())
{
fCurrentResponseUID = atoi(fNextToken);
fCurrentResponseUID = strtoul(fNextToken, nullptr, 10);
if (fCurrentResponseUID > fHighestRecordedUID)
fHighestRecordedUID = fCurrentResponseUID;
// size came before UID
@ -1233,7 +1233,7 @@ void nsImapServerResponseParser::msg_fetch()
{
bool sendEndMsgDownload = (GetDownloadingHeaders()
&& fReceivedHeaderOrSizeForUID == CurrentResponseUID());
fSizeOfMostRecentMessage = atoi(fNextToken);
fSizeOfMostRecentMessage = strtoul(fNextToken, nullptr, 10);
fReceivedHeaderOrSizeForUID = CurrentResponseUID();
if (sendEndMsgDownload)
{
@ -1969,7 +1969,7 @@ void nsImapServerResponseParser::resp_text_code()
AdvanceToNextToken();
if (ContinueParse())
{
fFolderUIDValidity = atoi(fNextToken);
fFolderUIDValidity = strtoul(fNextToken, nullptr, 10);
fHighestRecordedUID = 0;
AdvanceToNextToken();
}
@ -1979,7 +1979,7 @@ void nsImapServerResponseParser::resp_text_code()
AdvanceToNextToken();
if (ContinueParse())
{
fNumberOfUnseenMessages = atoi(fNextToken);
fNumberOfUnseenMessages = strtoul(fNextToken, nullptr, 10);
AdvanceToNextToken();
}
}
@ -1988,7 +1988,7 @@ void nsImapServerResponseParser::resp_text_code()
AdvanceToNextToken();
if (ContinueParse())
{
fStatusNextUID = atoi(fNextToken);
fStatusNextUID = strtoul(fNextToken, nullptr, 10);
AdvanceToNextToken();
}
}
@ -2004,7 +2004,7 @@ void nsImapServerResponseParser::resp_text_code()
AdvanceToNextToken();
if (ContinueParse())
{
fCurrentResponseUID = atoi(fNextToken);
fCurrentResponseUID = strtoul(fNextToken, nullptr, 10);
AdvanceToNextToken();
}
}

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

@ -260,7 +260,7 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(imapUrl);
bool useLocalCache = false;
folder->HasMsgOffline(atoi(msgKey.get()), &useLocalCache);
folder->HasMsgOffline(strtoul(msgKey.get(), nullptr, 10), &useLocalCache);
mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
nsCOMPtr<nsIURI> url = do_QueryInterface(imapUrl);
@ -583,7 +583,8 @@ nsresult nsImapService::FetchMimePart(nsIImapUrl *aImapUrl,
if (aImapMailFolder && msgurl && !messageIdentifierList.IsEmpty())
{
bool useLocalCache = false;
aImapMailFolder->HasMsgOffline(atoi(nsCString(messageIdentifierList).get()), &useLocalCache);
aImapMailFolder->HasMsgOffline(strtoul(nsCString(messageIdentifierList).get(), nullptr, 10),
&useLocalCache);
msgurl->SetMsgIsInLocalCache(useLocalCache);
}
rv = aImapUrl->SetImapMessageSink(aImapMessage);
@ -722,7 +723,7 @@ NS_IMETHODIMP nsImapService::CopyMessage(const char *aSrcMailboxURI,
nsAutoCString urlSpec;
char hierarchyDelimiter = GetHierarchyDelimiter(folder);
bool hasMsgOffline = false;
nsMsgKey key = atoi(msgKey.get());
nsMsgKey key = strtoul(msgKey.get(), nullptr, 10);
rv = CreateStartOfImapUrl(nsDependentCString(aSrcMailboxURI), getter_AddRefs(imapUrl),
folder, aUrlListener, urlSpec, hierarchyDelimiter);
@ -913,7 +914,7 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
bool hasMsgOffline = false;
if (folder)
folder->HasMsgOffline(atoi(msgKey.get()), &hasMsgOffline);
folder->HasMsgOffline(strtoul(msgKey.get(), nullptr, 10), &hasMsgOffline);
nsAutoCString urlSpec;
char hierarchyDelimiter = GetHierarchyDelimiter(folder);
@ -2621,7 +2622,8 @@ NS_IMETHODIMP nsImapService::NewURI(const nsACString &aSpec,
if (!messageIdString.IsEmpty())
{
bool useLocalCache = false;
msgFolder->HasMsgOffline(atoi(messageIdString.get()), &useLocalCache);
msgFolder->HasMsgOffline(strtoul(messageIdString.get(), nullptr, 10),
&useLocalCache);
mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
}
}

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

@ -1221,7 +1221,7 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI)
else
{
*aURI = nullptr;
uint32_t key = m_listOfMessageIds ? atoi(m_listOfMessageIds) : 0;
uint32_t key = m_listOfMessageIds ? strtoul(m_listOfMessageIds, nullptr, 10) : 0;
nsCString canonicalPath;
AllocateCanonicalPath(m_sourceCanonicalFolderPathSubString, m_onlineSubDirSeparator, (getter_Copies(canonicalPath)));
nsCString fullFolderPath("/");