From 028944299868615fdf24f89298745e910c231f4a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 25 Aug 2025 16:30:39 +0200 Subject: [PATCH] client: fix sizeof in open_unix_socket() Fix one of the sizeofs in open_unix_socket() to correctly specify sock_dir2 instead of sock_dir1. They have the same size, but don't rely on that. Fixes: 90d808ed2897 ("client: mitigate unsafe permissions change on chronyc socket") --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index 6c65b5b..66f23b7 100644 --- a/client.c +++ b/client.c @@ -270,7 +270,7 @@ open_unix_socket(char *server_path) if (snprintf(sock_dir1, sizeof (sock_dir1), "%s/chronyc.%d", sock_dir0, (int)getpid()) >= sizeof (sock_dir1) || snprintf(sock_dir2, sizeof (sock_dir2), - "%s/%s", sock_dir1, rand_dir) >= sizeof (sock_dir1) || + "%s/%s", sock_dir1, rand_dir) >= sizeof (sock_dir2) || snprintf(sock_path, sizeof (sock_path), "%s/sock", sock_dir2) >= sizeof (sock_path)) { LOG(LOGS_ERR, "Server socket path %s is too long", server_path);