]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smtp: check for and bail out on too short EHLO response
authorDaniel Stenberg <daniel@haxx.se>
Mon, 2 Sep 2019 21:04:26 +0000 (23:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 3 Sep 2019 06:25:23 +0000 (08:25 +0200)
Otherwise, a three byte response would make the smtp_state_ehlo_resp()
function misbehave.

Credit to OSS-Fuzz
Bug: https://crbug.com/oss-fuzz/16918

Assisted-by: Max Dymond
Closes #4287

lib/smtp.c

index 0db3c1e1c1c0d20a183f04385465d1549afed323..65220b0f683e8673dacbd665154f82cb94c44366 100644 (file)
@@ -714,7 +714,7 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
       result = CURLE_REMOTE_ACCESS_DENIED;
     }
   }
-  else {
+  else if(len >= 4) {
     line += 4;
     len -= 4;
 
@@ -785,6 +785,10 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
         result = smtp_perform_authentication(conn);
     }
   }
+  else {
+    failf(data, "Unexpectedly short EHLO response");
+    result = CURLE_WEIRD_SERVER_REPLY;
+  }
 
   return result;
 }