From 74abc42ea4b0aac92e954247935a7fe6ec4b86ed Mon Sep 17 00:00:00 2001 From: sindhu-krishnan <102755514+sindhu-krishnan@users.noreply.github.com> Date: Sat, 23 May 2026 13:57:53 +0530 Subject: [PATCH 1/2] Update libchronyctl.c --- libchronyctl/libchronyctl.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/libchronyctl/libchronyctl.c b/libchronyctl/libchronyctl.c index 06b8cb3..c6be8a8 100644 --- a/libchronyctl/libchronyctl.c +++ b/libchronyctl/libchronyctl.c @@ -669,12 +669,31 @@ int chronyctl_get_source_count(int *count) { RPY_N_Sources n_rpy; ret = receive_reply(sockfd, RPY_N_SOURCES, &n_rpy, offsetof(RPY_N_Sources, EOR)); - if (ret == CHRONYCTL_SUCCESS) - *count = (int)ntohl(n_rpy.source_count); + if (ret != CHRONYCTL_SUCCESS) { + close(sockfd); cleanup_local_socket(); + return ret; + } + + uint32_t total = ntohl(n_rpy.source_count); + int resolved_count = 0; + for (uint32_t i = 0; i < total; i++) { + REQ_Source_Data sd_req; + memset(&sd_req, 0, sizeof(sd_req)); + sd_req.index = htonl(i); + if (send_request(sockfd, REQ_SOURCE_DATA, &sd_req, sizeof(sd_req)) != 0) + continue; + RPY_Source_Data sd_rpy; + if (receive_reply(sockfd, RPY_SOURCE_DATA, &sd_rpy, offsetof(RPY_Source_Data, EOR)) != CHRONYCTL_SUCCESS) + continue; + uint16_t fam = ntohs(sd_rpy.ip_address.family); + if (fam == IPADDR_INET4 || fam == IPADDR_INET6) + resolved_count++; + } + *count = resolved_count; close(sockfd); cleanup_local_socket(); - return ret; + return CHRONYCTL_SUCCESS; } int chronyctl_waitsync(int max_tries, int interval_sec) { From cb8d77dea81dfeb28c65eff3d55fe176d22b4d28 Mon Sep 17 00:00:00 2001 From: sindhu-krishnan <102755514+sindhu-krishnan@users.noreply.github.com> Date: Mon, 25 May 2026 17:04:30 +0530 Subject: [PATCH 2/2] Update libchronyctl.c --- libchronyctl/libchronyctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libchronyctl/libchronyctl.c b/libchronyctl/libchronyctl.c index c6be8a8..24391e3 100644 --- a/libchronyctl/libchronyctl.c +++ b/libchronyctl/libchronyctl.c @@ -693,7 +693,7 @@ int chronyctl_get_source_count(int *count) { close(sockfd); cleanup_local_socket(); - return CHRONYCTL_SUCCESS; + return CHRONYCTL_SUCCESS; } int chronyctl_waitsync(int max_tries, int interval_sec) {