From: Alan T. DeKok Date: Thu, 10 Nov 2022 17:01:13 +0000 (+0000) Subject: close FD on error in more cases X-Git-Tag: release_3_2_2~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3fb37b19d1e9b9e6dca642cbf5bc098851e1870d;p=thirdparty%2Ffreeradius-server.git close FD on error in more cases --- diff --git a/src/main/listen.c b/src/main/listen.c index 43ced2cce0..7d137318ae 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -3134,6 +3134,8 @@ rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t if (this->nonblock) { if (fr_nonblock(this->fd) < 0) { ERROR("(TLS) Failed setting nonblocking for proxy socket '%s' - %s", buffer, fr_strerror()); + error: + close(this->fd); home->last_failed_open = now; listen_free(&this); return NULL; @@ -3143,8 +3145,7 @@ rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t if (!rbtree_insert(home->listeners, this)) { ERROR("(TLS) Failed adding tracking informtion for proxy socket '%s'", buffer); - listen_free(&this); - return NULL; + goto error; } } @@ -3154,9 +3155,7 @@ rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t sock->ssn = tls_new_client_session(sock, home->tls, this->fd, &sock->certs); if (!sock->ssn) { ERROR("(TLS) Failed opening connection on proxy socket '%s'", buffer); - home->last_failed_open = now; - listen_free(&this); - return NULL; + goto error; } sock->connect_timeout = home->connect_timeout; @@ -3222,17 +3221,13 @@ rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t &sizeof_src) < 0) { ERROR("Failed getting socket name for '%s': %s", buffer, fr_syserror(errno)); - home->last_failed_open = now; - listen_free(&this); - return NULL; + goto error; } if (!fr_sockaddr2ipaddr(&src, sizeof_src, &sock->my_ipaddr, &sock->my_port)) { ERROR("Socket has unsupported address family for '%s'", buffer); - home->last_failed_open = now; - listen_free(&this); - return NULL; + goto error; } this->print(this, buffer, sizeof(buffer));