]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: fix socket wait activity in ftp_domore_getsock
authorStefan Eissing <stefan@eissing.org>
Fri, 9 Feb 2024 12:10:08 +0000 (13:10 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 9 Feb 2024 14:57:06 +0000 (15:57 +0100)
- when waiting on the data connection, always add the control socket to
  the pollset on state STOP or let the pingpong add the socket according
  to its needs.

Reported-by: Fabian Vogt
Fixes #12901
Closes #12913

lib/ftp.c

index e0590a61eb8c79d43d95b11188add6d271154802..53445b3d5a5fdc875a58b8bcdbf9418f93ff2efd 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -937,24 +937,18 @@ static int ftp_domore_getsock(struct Curl_easy *data,
    * remote site, or we could wait for that site to connect to us. Or just
    * handle ordinary commands.
    */
-
   DEBUGF(infof(data, "ftp_domore_getsock()"));
-  if(conn->cfilter[SECONDARYSOCKET]
-     && !Curl_conn_is_connected(conn, SECONDARYSOCKET))
-    return 0;
 
   if(FTP_STOP == ftpc->state) {
-    int bits = GETSOCK_READSOCK(0);
-
     /* if stopped and still in this state, then we're also waiting for a
        connect on the secondary connection */
+    DEBUGASSERT(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD ||
+               (conn->cfilter[SECONDARYSOCKET] &&
+                !Curl_conn_is_connected(conn, SECONDARYSOCKET)));
     socks[0] = conn->sock[FIRSTSOCKET];
-    if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
-      socks[1] = conn->sock[SECONDARYSOCKET];
-      bits |= GETSOCK_WRITESOCK(1) | GETSOCK_READSOCK(1);
-    }
-
-    return bits;
+    /* An unconnected SECONDARY will add its socket by itself
+     * via its adjust_pollset() */
+    return GETSOCK_READSOCK(0);
   }
   return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks);
 }