Bug 1487082 - Fix unsafe use of NS_ConvertASCIItoUTF16(). r=jorgk
authorBen Campbell <benc@thunderbird.net>
Mon, 17 Sep 2018 16:38:28 +1200
changeset 33173 50da05f6af45c6aa572428c1d86320a02c527969
parent 33172 71ff55c3ec2e94de01c94a8de546f15e6a3f7d75
child 33174 2977f7b7b8d661f1bd377786f3add1c1aa551d80
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1487082
Bug 1487082 - Fix unsafe use of NS_ConvertASCIItoUTF16(). r=jorgk
mailnews/compose/src/nsSmtpProtocol.cpp
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -2301,20 +2301,22 @@ nsSmtpProtocol::GetUsernamePassword(nsAC
     }
     // empty password
 
     aPassword.Truncate();
 
     nsCString hostname;
     rv = smtpServer->GetHostname(hostname);
     NS_ENSURE_SUCCESS(rv, rv);
+    nsAutoString hostnameUTF16;
+    CopyASCIItoUTF16(hostname, hostnameUTF16);
 
     const char16_t *formatStrings[] =
     {
-      NS_ConvertASCIItoUTF16(hostname).get(),
+      hostnameUTF16.get(),
       nullptr
     };
 
     rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
     NS_ENSURE_SUCCESS(rv,rv);
     return rv;
 }