When -b is used rpki-client should bind to that address for outgoing
connections. The http code does that but only warns if a bind call fails
but try the connect none the less. This is different from other network
tools (nc, ftp, telnet). So change this to a real error.

-- 
:wq Claudio

Index: http.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v
retrieving revision 1.18
diff -u -p -r1.18 http.c
--- http.c      6 Apr 2021 12:35:24 -0000       1.18
+++ http.c      7 Apr 2021 10:50:43 -0000
@@ -493,8 +493,14 @@ http_connect(struct http_connection *con
 
                if (http_bindaddr.ss_family == res->ai_family) {
                        if (bind(conn->fd, (struct sockaddr *)&http_bindaddr,
-                           res->ai_addrlen) == -1)
-                               warn("%s: bind", http_info(conn->url));
+                           res->ai_addrlen) == -1) {
+                               save_errno = errno;
+                               close(conn->fd);
+                               conn->fd = -1;
+                               errno = save_errno;
+                               cause = "bind";
+                               continue;
+                       }
                }
 
                if (connect(conn->fd, res->ai_addr, res->ai_addrlen) == -1) {

Reply via email to