Rocco Rutte:
[apps/madmutt.git] / imap / auth_sasl.c
index 49c09a3..075e4b5 100644 (file)
@@ -1,19 +1,10 @@
 /*
+ * Copyright notice from original mutt:
  * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com>
- * 
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- * 
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
  */
 
 /* SASL login/authentication code */
 #include "imap_private.h"
 #include "auth.h"
 
+#include "lib/mem.h"
+#include "lib/intl.h"
+#include "lib/debug.h"
+
 #ifdef USE_SASL2
 #include <sasl/sasl.h>
 #include <sasl/saslutil.h>
@@ -53,8 +48,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
   unsigned char client_start;
 
   if (mutt_sasl_client_new (idata->conn, &saslconn) < 0) {
-    dprint (1, (debugfile,
-                "imap_auth_sasl: Error allocating SASL connection.\n"));
+    debug_print (1, ("Error allocating SASL connection.\n"));
     return IMAP_AUTH_FAILURE;
   }
 
@@ -103,11 +97,9 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
 
   if (rc != SASL_OK && rc != SASL_CONTINUE) {
     if (method)
-      dprint (2, (debugfile, "imap_auth_sasl: %s unavailable\n", method));
+      debug_print (2, ("%s unavailable\n", method));
     else
-      dprint (1,
-              (debugfile,
-               "imap_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
+      debug_print (1, ("Failure starting authentication exchange. No shared mechanisms?\n"));
     /* SASL doesn't support LOGIN, so fall back */
 
     return IMAP_AUTH_UNAVAIL;
@@ -126,7 +118,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
     while (irc == IMAP_CMD_CONTINUE);
 
     if (method && irc == IMAP_CMD_NO) {
-      dprint (2, (debugfile, "imap_auth_sasl: %s failed\n", method));
+      debug_print (2, ("%s failed\n", method));
       sasl_dispose (&saslconn);
       return IMAP_AUTH_UNAVAIL;
     }
@@ -137,15 +129,13 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
     if (irc == IMAP_CMD_RESPOND) {
 #ifdef USE_SASL2
       if (sasl_decode64
-          (idata->cmd.buf + 2, strlen (idata->cmd.buf + 2), buf,
+          (idata->cmd.buf + 2, safe_strlen (idata->cmd.buf + 2), buf,
            LONG_STRING - 1,
 #else
-      if (sasl_decode64 (idata->cmd.buf + 2, strlen (idata->cmd.buf + 2), buf,
+      if (sasl_decode64 (idata->cmd.buf + 2, safe_strlen (idata->cmd.buf + 2), buf,
 #endif
                          &len) != SASL_OK) {
-        dprint (1,
-                (debugfile,
-                 "imap_auth_sasl: error base64-decoding server response.\n"));
+        debug_print (1, ("error base64-decoding server response.\n"));
         goto bail;
       }
     }
@@ -164,9 +154,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
     /* send out response, or line break if none needed */
     if (olen) {
       if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) {
-        dprint (1,
-                (debugfile,
-                 "imap_auth_sasl: error base64-encoding client response.\n"));
+        debug_print (1, ("error base64-encoding client response.\n"));
         goto bail;
       }
 
@@ -185,8 +173,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
     /* If SASL has errored out, send an abort string to the server */
     if (rc < 0) {
       mutt_socket_write (idata->conn, "*\r\n");
-      dprint (1,
-              (debugfile, "imap_auth_sasl: sasl_client_step error %d\n", rc));
+      debug_print (1, ("sasl_client_step error %d\n", rc));
     }
 
     olen = 0;