From: Alan T. DeKok Date: Mon, 6 Feb 2023 20:46:16 +0000 (-0500) Subject: enfore connected sockets for TCP, and check for hash table X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b027519a424b76208bb6cda3b63b10208f6a9827;p=thirdparty%2Ffreeradius-server.git enfore connected sockets for TCP, and check for hash table before dereferencing it --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index fe89530dd90..f17a53b49a7 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -1950,9 +1950,11 @@ static void client_expiry_timer(fr_event_list_t *el, fr_time_t now, void *uctx) if (connection) { fr_io_client_t *parent = connection->parent; - pthread_mutex_lock(&parent->mutex); - (void) fr_hash_table_delete(parent->ht, connection); - pthread_mutex_unlock(&parent->mutex); + if (parent->ht) { + pthread_mutex_lock(&parent->mutex); + (void) fr_hash_table_delete(parent->ht, connection); + pthread_mutex_unlock(&parent->mutex); + } /* * Mark the connection as dead, and tell diff --git a/src/lib/server/client.c b/src/lib/server/client.c index 7576f56b474..17a838d3082 100644 --- a/src/lib/server/client.c +++ b/src/lib/server/client.c @@ -558,6 +558,11 @@ RADCLIENT_LIST *client_list_parse_section(CONF_SECTION *section, int proto, TLS_ return NULL; } + /* + * TCP sockets are always connected. + */ + c->use_connected |= (c->proto == IPPROTO_TCP); + #ifdef WITH_TLS /* * TLS clients CANNOT use non-TLS listeners.