From: Miroslav Lichvar Date: Mon, 25 Aug 2025 14:30:39 +0000 (+0200) Subject: client: fix sizeof in open_unix_socket() X-Git-Tag: 4.8~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=028944299868615fdf24f89298745e910c231f4a;p=thirdparty%2Fchrony.git 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") --- diff --git a/client.c b/client.c index 6c65b5bf..66f23b70 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);