diff mbox series

[1/7] RADIUS DAS: Initialize socket to -1 before bind

Message ID 20261019063814.59324-2-seb@bionic.network
State New
Headers show
Series RADIUS/TLS reverse CoA (draft-ietf-radext-reverse-coa) | expand

Commit Message

Seb Adamski Oct. 19, 2026, 6:38 a.m. UTC
radius_das_init() allocates the context with os_zalloc(), so das->sock
is 0 until radius_das_open_socket() returns. If os_memdup() of the
shared secret fails before that, radius_das_deinit() sees sock >= 0 and
closes file descriptor 0, which belongs to someone else.

Mark the socket as not open right after the allocation.

Signed-off-by: Seb Adamski <seb@bionic.network>
---
 src/radius/radius_das.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/src/radius/radius_das.c b/src/radius/radius_das.c
index 8d7c9b4c4..d3d9f75ec 100644
--- a/src/radius/radius_das.c
+++ b/src/radius/radius_das.c
@@ -556,6 +556,7 @@  radius_das_init(struct radius_das_conf *conf)
 	if (das == NULL)
 		return NULL;
 
+	das->sock = -1;
 	das->time_window = conf->time_window;
 	das->require_event_timestamp = conf->require_event_timestamp;
 	das->require_message_authenticator =