]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
setup_transfer: deal with both sockets being -1
authorDaniel Stenberg <daniel@haxx.se>
Fri, 11 May 2018 21:54:26 +0000 (23:54 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 11 May 2018 21:56:37 +0000 (23:56 +0200)
Detected by Coverity; CID 1435559.  Follow-up to f8d608f38d00. It would
index the array with -1 if neither index was a socket.

lib/transfer.c

index 6bf95c576fec399ef30a0a5ecbfb3c1bd5f023db..131f2dc7c0bf4e93468255bda1640d55ef70dd0d 100644 (file)
@@ -2021,7 +2021,8 @@ Curl_setup_transfer(
   if(conn->bits.multiplex || conn->httpversion == 20) {
     /* when multiplexing, the read/write sockets need to be the same! */
     conn->sockfd = sockindex == -1 ?
-      conn->sock[writesockindex] : conn->sock[sockindex];
+      ((writesockindex == -1 ? CURL_SOCKET_BAD : conn->sock[writesockindex])) :
+      conn->sock[sockindex];
     conn->writesockfd = conn->sockfd;
   }
   else {