AUTH PLAIN: password length has to be its own variable, else it may contain invalid...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index 760ea5a82d2b7d2e03d16710a0ce7f5793ea03cc..892d8e7a7885d4aef9e851923284b9e0a9057333 100644 (file)
@@ -446,7 +446,8 @@ void smtp_try_plain(long offset, long Flags)
        int result;
 
        long decoded_len;
-       long len;
+       long len = 0;
+       long plen = 0;
 
        memset(pass, 0, sizeof(pass));
        decoded_len = StrBufDecodeBase64(sSMTP->Cmd);
@@ -470,10 +471,10 @@ void smtp_try_plain(long offset, long Flags)
 
                if (decoded_len > 0)
                {
-                       len = safestrncpy(pass, decoded_authstring, sizeof pass);
+                       plen = safestrncpy(pass, decoded_authstring, sizeof pass);
 
-                       if (len < 0)
-                               len = sizeof(pass) - 1;
+                       if (plen < 0)
+                               plen = sizeof(pass) - 1;
                }
        }
 
@@ -487,7 +488,7 @@ void smtp_try_plain(long offset, long Flags)
        }
 
        if (result == login_ok) {
-               if (CtdlTryPassword(pass, len) == pass_ok) {
+               if (CtdlTryPassword(pass, plen) == pass_ok) {
                        smtp_webcit_preferences_hack();
                        smtp_auth_greeting(offset, Flags);
                        return;