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