Bug 1907691 - Fix Crash in [@ strlen | nsCharTraits<T>::length] via nsImapServerResponseParser::mailbox and nsImapServerResponseParser::ParseIMAPServerResponse. r=tobyp

Differential Revision: https://phabricator.services.mozilla.com/D222093

--HG--
extra : rebase_source : 741e023bb1b07f6cebab8a4d8404ebffb4c403a4
This commit is contained in:
Magnus Melin 2024-09-16 06:59:27 +00:00
Родитель 72733c5e07
Коммит 28d02b714b
1 изменённых файлов: 25 добавлений и 6 удалений

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

@ -577,7 +577,10 @@ void nsImapServerResponseParser::response_data() {
if (!fNextToken) if (!fNextToken)
SetSyntaxError(true); SetSyntaxError(true);
else { else {
fMailAccountUrl.Adopt(CreateAstring()); char* str = CreateAstring();
if (str) {
fMailAccountUrl.Adopt(str);
}
AdvanceToNextToken(); AdvanceToNextToken();
} }
} else } else
@ -785,7 +788,10 @@ void nsImapServerResponseParser::mailbox(nsImapMailboxSpec* boxSpec) {
if (xlistInbox) PR_Free(CreateAstring()); if (xlistInbox) PR_Free(CreateAstring());
AdvanceToNextToken(); AdvanceToNextToken();
} else { } else {
boxname = nsDependentCString(CreateAstring()); char* name = CreateAstring();
if (name) {
boxname.Adopt(name);
}
AdvanceToNextToken(); AdvanceToNextToken();
} }
@ -2091,7 +2097,9 @@ void nsImapServerResponseParser::myrights_data(bool unsolicited) {
mailboxName = strdup(fSelectedMailboxName); mailboxName = strdup(fSelectedMailboxName);
} else { } else {
mailboxName = CreateAstring(); mailboxName = CreateAstring();
if (mailboxName) AdvanceToNextToken(); if (mailboxName) {
AdvanceToNextToken();
}
} }
if (mailboxName) { if (mailboxName) {
if (ContinueParse()) { if (ContinueParse()) {
@ -2163,7 +2171,11 @@ void nsImapServerResponseParser::quota_data() {
nsCString quotaroot; nsCString quotaroot;
AdvanceToNextToken(); AdvanceToNextToken();
while (ContinueParse() && !fAtEndOfLine) { while (ContinueParse() && !fAtEndOfLine) {
quotaroot.Adopt(CreateAstring()); char* root = CreateAstring();
if (!root) {
break;
}
quotaroot.Adopt(root);
AdvanceToNextToken(); AdvanceToNextToken();
} }
// Invalidate any previously stored quota data. Updated QUOTA data follows. // Invalidate any previously stored quota data. Updated QUOTA data follows.
@ -2174,7 +2186,10 @@ void nsImapServerResponseParser::quota_data() {
AdvanceToNextToken(); AdvanceToNextToken();
if (ContinueParse()) { if (ContinueParse()) {
nsCString quotaroot; nsCString quotaroot;
quotaroot.Adopt(CreateAstring()); char* root = CreateAstring();
if (root) {
quotaroot.Adopt(root);
}
nsCString resource; nsCString resource;
AdvanceToNextToken(); AdvanceToNextToken();
if (fNextToken) { if (fNextToken) {
@ -2186,7 +2201,11 @@ void nsImapServerResponseParser::quota_data() {
// STORAGE in KBytes. A mailbox can have multiple quotaroots but // STORAGE in KBytes. A mailbox can have multiple quotaroots but
// typically only one and with a single resource. // typically only one and with a single resource.
while (ContinueParse() && !fAtEndOfLine) { while (ContinueParse() && !fAtEndOfLine) {
resource.Adopt(CreateAstring()); char* res = CreateAstring();
if (!res) {
break;
}
resource.Adopt(res);
AdvanceToNextToken(); AdvanceToNextToken();
usage = atoll(fNextToken); usage = atoll(fNextToken);
AdvanceToNextToken(); AdvanceToNextToken();