]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: fix sizeof in open_unix_socket()
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 25 Aug 2025 14:30:39 +0000 (16:30 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Aug 2025 07:59:37 +0000 (09:59 +0200)
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

index 6c65b5bf8c21afbaabda366c366bad231d9e041d..66f23b70f3ebadccd8cc7295141ebaf8d3754a6a 100644 (file)
--- 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);