]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: add failure reason on bind errors
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>
Thu, 18 Jul 2024 09:52:31 +0000 (12:52 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 18 Jul 2024 12:47:00 +0000 (14:47 +0200)
Closes #14221

lib/cf-socket.c

index 5040bb6bc38861ae2a5755c58052856dcd660485..2e92db29d30211f0310fe005c325dc77c15a7571 100644 (file)
@@ -634,7 +634,10 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
       case IF2IP_NOT_FOUND:
         if(iface_input && !host_input) {
           /* Do not fall back to treating it as a hostname */
-          failf(data, "Couldn't bind to interface '%s'", iface);
+          char buffer[STRERROR_LEN];
+          data->state.os_errno = error = SOCKERRNO;
+          failf(data, "Couldn't bind to interface '%s' with errno %d: %s",
+                iface, error, Curl_strerror(error, buffer, sizeof(buffer)));
           return CURLE_INTERFACE_FAILED;
         }
         break;
@@ -740,8 +743,11 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
       /* errorbuf is set false so failf will overwrite any message already in
          the error buffer, so the user receives this error message instead of a
          generic resolve error. */
+      char buffer[STRERROR_LEN];
       data->state.errorbuf = FALSE;
-      failf(data, "Couldn't bind to '%s'", host);
+      data->state.os_errno = error = SOCKERRNO;
+      failf(data, "Couldn't bind to '%s' with errno %d: %s",
+            host, error, Curl_strerror(error, buffer, sizeof(buffer)));
       return CURLE_INTERFACE_FAILED;
     }
   }