]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smtp: for starttls, do full upgrade
authorStefan Eissing <stefan@eissing.org>
Mon, 15 Jul 2024 09:33:58 +0000 (11:33 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 15 Jul 2024 21:11:21 +0000 (23:11 +0200)
- make sure the TLS handshake after a successful STARTTLS command is
  fully done before further sending/receiving on the connection.

Reported-by: tomy2105 on github
Fixes #14166
Closes #14190

lib/smtp.c

index ec759982455afa0149dc2eb2818b733496f88efc..5ee1b5ea37ac4c97a3483a326f3c1b15f556086d 100644 (file)
@@ -1202,6 +1202,7 @@ static CURLcode smtp_statemachine(struct Curl_easy *data,
   size_t nread = 0;
 
   /* Busy upgrading the connection; right now all I/O is SSL/TLS, not SMTP */
+upgrade_tls:
   if(smtpc->state == SMTP_UPGRADETLS)
     return smtp_perform_upgrade_tls(data);
 
@@ -1238,6 +1239,10 @@ static CURLcode smtp_statemachine(struct Curl_easy *data,
 
     case SMTP_STARTTLS:
       result = smtp_state_starttls_resp(data, smtpcode, smtpc->state);
+      /* During UPGRADETLS, leave the read loop as we need to connect
+       * (e.g. TLS handshake) before we continue sending/receiving. */
+      if(!result && (smtpc->state == SMTP_UPGRADETLS))
+        goto upgrade_tls;
       break;
 
     case SMTP_AUTH: