Bug 1000851 - Follow-up: Correct buffer size. r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Wed, 29 Aug 2018 09:35:41 +0200
changeset 31869 70d7b8ada4ecb939ac39848eb39b22e526d062e0
parent 31868 90e2c9058adcff296ebfafd71acd601232211087
child 31870 ffe25f93f1e9ab89de12cbfded77c11108f93003
push id88
push usermozilla@jorgk.com
push dateSun, 14 Oct 2018 20:34:25 +0000
treeherdercomm-esr60@18a94aeb864e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1000851
Bug 1000851 - Follow-up: Correct buffer size. r=mkmelin a=jorgk
mailnews/compose/src/nsSmtpProtocol.cpp
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -1516,19 +1516,19 @@ nsresult nsSmtpProtocol::AuthLoginStep1(
     if (username.Length() > 255)  // RFC 4616: authcid; up to 255 octets
       username.Truncate(255);
     if (passwordUTF8.Length() > 255)  // RFC 4616: passwd; up to 255 octets
       passwordUTF8.Truncate(255);
 
     // RFC 4616: UTF8NUL authcid UTF8NUL passwd
     char plain_string[513];
     memset(plain_string, 0, 513);
-    PR_snprintf(&plain_string[1], 255, "%s", username.get());
+    PR_snprintf(&plain_string[1], 256, "%s", username.get());
     int len = username.Length() + 2;  // We include two <NUL> characters.
-    PR_snprintf(&plain_string[len], 255, "%s", passwordUTF8.get());
+    PR_snprintf(&plain_string[len], 256, "%s", passwordUTF8.get());
     len += passwordUTF8.Length();
 
     base64Str = PL_Base64Encode(plain_string, len, nullptr);
     PR_snprintf(buffer, sizeof(buffer), "AUTH PLAIN %s" CRLF, base64Str);
   }
   else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED)
   {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("LOGIN auth"));