]> granicus.if.org Git - curl/commitdiff
pop3: only do APOP with a valid timestamp
authorDaniel Stenberg <daniel@haxx.se>
Thu, 15 Nov 2018 16:00:16 +0000 (17:00 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 16 Nov 2018 22:36:53 +0000 (23:36 +0100)
Brought-by: bobmitchell1956 on github
Fixes #3278
Closes #3279

lib/pop3.c

index 5e0fd2299beb86f6a7ade1ce52be1940c0c2471c..c1f974d40f216fe691e976501b85c1037ad306b9 100644 (file)
@@ -629,6 +629,7 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
         if(line[i] == '<') {
           /* Calculate the length of the timestamp */
           size_t timestamplen = len - 1 - i;
+          char *at;
           if(!timestamplen)
             break;
 
@@ -642,8 +643,15 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
           memcpy(pop3c->apoptimestamp, line + i, timestamplen);
           pop3c->apoptimestamp[timestamplen] = '\0';
 
-          /* Store the APOP capability */
-          pop3c->authtypes |= POP3_TYPE_APOP;
+          /* If the timestamp does not contain '@' it is not (as required by
+             RFC-1939) conformant to the RFC-822 message id syntax, and we
+             therefore do not use APOP authentication. */
+          at = strchr(pop3c->apoptimestamp, '@');
+          if(!at)
+            Curl_safefree(pop3c->apoptimestamp);
+          else
+            /* Store the APOP capability */
+            pop3c->authtypes |= POP3_TYPE_APOP;
           break;
         }
       }