]> Pileus Git - ~andy/fetchmail/blobdiff - pop3.c
Add CVE ID for recent DoS: CVE-2006-0321
[~andy/fetchmail] / pop3.c
diff --git a/pop3.c b/pop3.c
index 674894698f217fb3abdb96ad76774ff5709dcff3..d3bba8d53992f6a036c02fb044fd8f9c63aaa1b7 100644 (file)
--- a/pop3.c
+++ b/pop3.c
 #include <opie.h>
 #endif /* OPIE_ENABLE */
 
-static int last;
-#ifdef SDPS_ENABLE
-char *sdps_envfrom;
-char *sdps_envto;
-#endif /* SDPS_ENABLE */
+/* global variables: please reinitialize them explicitly for proper
+ * working in daemon mode */
 
+/* TODO: session variables to be initialized before server greeting */
 #ifdef OPIE_ENABLE
 static char lastok[POPBUFSIZE+1];
 #endif /* OPIE_ENABLE */
 
-/* these variables are shared between the CAPA probe and the authenticator */
+/* session variables initialized in capa_probe() or pop3_getauth() */
 #if defined(GSSAPI)
-    flag has_gssapi = FALSE;
+flag has_gssapi = FALSE;
 #endif /* defined(GSSAPI) */
 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
-    flag has_kerberos = FALSE;
+flag has_kerberos = FALSE;
 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
-    static flag has_cram = FALSE;
+static flag has_cram = FALSE;
 #ifdef OPIE_ENABLE
-    flag has_otp = FALSE;
+flag has_otp = FALSE;
 #endif /* OPIE_ENABLE */
 #ifdef SSL_ENABLE
-    static flag has_ssl = FALSE;
+static flag has_ssl = FALSE;
 #endif /* SSL_ENABLE */
 
+/* mailbox variables initialized in pop3_getrange() */
+static int last;
+
+/* mail variables initialized in pop3_fetch() */
+#ifdef SDPS_ENABLE
+char *sdps_envfrom;
+char *sdps_envto;
+#endif /* SDPS_ENABLE */
+
 #ifdef NTLM_ENABLE
 #include "ntlm.h"
 
-static tSmbNtlmAuthRequest   request;             
-static tSmbNtlmAuthChallenge challenge;
-static tSmbNtlmAuthResponse  response;
-
 /*
  * NTLM support by Grant Edwards.
  *
@@ -72,6 +75,10 @@ static tSmbNtlmAuthResponse  response;
 static int do_pop3_ntlm(int sock, struct query *ctl,
        int msn_instead /** if true, send AUTH MSN, else send AUTH NTLM */)
 {
+    tSmbNtlmAuthRequest request;
+    tSmbNtlmAuthChallenge challenge;
+    tSmbNtlmAuthResponse response;
+
     char msgbuf[2048];
     int result,len;
   
@@ -306,6 +313,31 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
     has_ssl = FALSE;
 #endif /* SSL_ENABLE */
 
+    /* Set this up before authentication quits early. */
+    set_peek_capable(ctl);
+    /*
+     * The "Maillennium POP3/PROXY server" deliberately truncates
+     * TOP replies after c. 64 or 80 kByte (we have varying reports), so
+     * disable TOP. Comcast once spewed marketing babble to the extent
+     * of protecting Outlook -- pretty overzealous to break a protocol
+     * for that that Microsoft could have read, too. Comcast aren't
+     * alone in using this software though.
+     * <http://lists.ccil.org/pipermail/fetchmail-friends/2004-April/008523.html>
+     * (Thanks to Ed Wilts for reminding me of that.)
+     *
+     * The warning is printed once per server, until fetchmail exits.
+     * It will be suppressed when --fetchall or other circumstances make
+     * us use RETR anyhow.
+     *
+     * Matthias Andree
+     */
+    if (peek_capable && strstr(greeting, "Maillennium POP3/PROXY server")) {
+       if ((ctl->server.workarounds & WKA_TOP) == 0) {
+           report(stdout, GT_("Warning: \"Maillennium POP3/PROXY server\" found, using RETR command instead of TOP.\n"));
+           ctl->server.workarounds |= WKA_TOP;
+       }
+       peek_capable = 0;
+    }
     if (ctl->server.authenticate == A_SSH) {
         return PS_SUCCESS;
     }
@@ -603,8 +635,6 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
     sleep(3); /* to be _really_ safe, probably need sleep(5)! */
 #endif
 
-    set_peek_capable(ctl);
-
     /* we're approved */
     return(PS_SUCCESS);
 }
@@ -1266,12 +1296,11 @@ int doPOP3 (struct query *ctl)
 {
 #ifndef MBOX
     if (ctl->mailboxes->id) {
-       fprintf(stderr,GT_("Option --remote is not supported with POP3\n"));
+       fprintf(stderr,GT_("Option --folder is not supported with POP3\n"));
        return(PS_SYNTAX);
     }
 #endif /* MBOX */
-    set_peek_capable(ctl); /* XXX FIXME: is this needed or do we always
-                             call this from pop3_getauth anyways? */
+
     return(do_protocol(ctl, &pop3));
 }
 #endif /* POP3_ENABLE */