Bug 1933078 - Stop using sprintf r=BenC

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
longsonr 2024-11-25 20:06:15 +00:00
Родитель cb9774bd86
Коммит 0cc2c027e1
5 изменённых файлов: 10 добавлений и 27 удалений

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

@ -2649,11 +2649,11 @@ void nsImapProtocol::IncrementCommandTagNumber() {
} else if (++m_currentServerCommandTagNumber == 0) {
m_currentServerCommandTagNumber = 1;
}
sprintf(m_currentServerCommandTag, "%u", m_currentServerCommandTagNumber);
m_currentServerCommandTag = nsPrintfCString("%u", m_currentServerCommandTagNumber);
}
const char* nsImapProtocol::GetServerCommandTag() {
return m_currentServerCommandTag;
return m_currentServerCommandTag.get();
}
/**

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

@ -534,9 +534,7 @@ class nsImapProtocol : public nsIImapProtocol,
RefPtr<nsImapFlagAndUidState> m_flagState;
nsMsgBiffState m_currentBiffState;
// manage the IMAP server command tags
// 11 = enough memory for the decimal representation of MAX_UINT + trailing
// nul
char m_currentServerCommandTag[11];
nsCString m_currentServerCommandTag;
uint32_t m_currentServerCommandTagNumber;
void IncrementCommandTagNumber();
const char* GetServerCommandTag();

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

@ -1067,13 +1067,10 @@ void nsImapServerResponseParser::msg_fetch() {
if (fSizeOfMostRecentMessage == 0 && CurrentResponseUID()) {
// on no, bogus Netscape 2.0 mail server bug
char uidString[100];
sprintf(uidString, "%ld", (long)CurrentResponseUID());
if (!fZeroLengthMessageUidString.IsEmpty())
fZeroLengthMessageUidString += ",";
fZeroLengthMessageUidString += uidString;
fZeroLengthMessageUidString.AppendInt(CurrentResponseUID());
}
// if this token ends in ')', then it is the last token

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

@ -276,20 +276,14 @@ static void MimePgpe_free(MimeClosure output_closure) {
This is not a full URL, just a part-number.
*/
static nsCString determineMimePart(MimeObject* obj) {
char mimePartNum[20];
MimeObject* kid;
MimeContainer* cont;
int32_t i;
nsCString mimePart;
while (obj->parent) {
cont = (MimeContainer*)obj->parent;
for (i = 0; i < cont->nchildren; i++) {
kid = cont->children[i];
auto* cont = (MimeContainer*)obj->parent;
for (int32_t i = 0; i < cont->nchildren; i++) {
auto* kid = cont->children[i];
if (kid == obj) {
sprintf(mimePartNum, ".%d", i + 1);
mimePart.Insert(mimePartNum, 0);
mimePart.Insert(nsPrintfCString(".%d", i + 1), 0);
}
}
obj = obj->parent;

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

@ -22,12 +22,9 @@ nsMimeXmlEmitter::~nsMimeXmlEmitter(void) {}
// anything to the stream since these may be image data
// output streams, etc...
nsresult nsMimeXmlEmitter::Complete() {
char buf[16];
// Now write out the total count of attachments for this message
UtilityWrite("<mailattachcount>");
sprintf(buf, "%d", mAttachCount);
UtilityWrite(buf);
UtilityWrite(nsPrintfCString("%d", mAttachCount));
UtilityWrite("</mailattachcount>");
UtilityWrite("</message>");
@ -126,12 +123,9 @@ nsresult nsMimeXmlEmitter::StartAttachment(const nsACString& name,
const char* contentType,
const char* url,
bool aIsExternalAttachment) {
char buf[128];
++mAttachCount;
sprintf(buf, "<mailattachment id=\"%d\">", mAttachCount);
UtilityWrite(buf);
UtilityWrite(nsPrintfCString("<mailattachment id=\"%d\">", mAttachCount));
AddAttachmentField(HEADER_PARM_FILENAME, PromiseFlatCString(name).get());
return NS_OK;