]> granicus.if.org Git - curl/commitdiff
connect: improve the bind error message
authorJay Satiro <raysatiro@yahoo.com>
Thu, 23 Nov 2017 07:47:26 +0000 (02:47 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Thu, 23 Nov 2017 07:47:26 +0000 (02:47 -0500)
eg consider a non-existent interface eth8, curl --interface eth8

Before: curl: (45) Could not resolve host: eth8
After: curl: (45) Couldn't bind to 'eth8'

Bug: https://github.com/curl/curl/issues/2104
Reported-by: Alfonso Martone
lib/connect.c

index 16104bc4ff038d831b2704abd6ab1aa4281c04f8..45e18bc07bf275324ea5021b1c02472e16baa8a9 100644 (file)
@@ -412,6 +412,10 @@ static CURLcode bindlocal(struct connectdata *conn,
     }
 
     if(done < 1) {
+      /* 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. */
+      data->state.errorbuf = FALSE;
       failf(data, "Couldn't bind to '%s'", dev);
       return CURLE_INTERFACE_FAILED;
     }