]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesync: verify the actual size of the received data
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 16 Apr 2026 09:13:27 +0000 (11:13 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 16 Apr 2026 18:19:02 +0000 (19:19 +0100)
iov.iov_len doesn't change after calling recvmsg() so it remains set to
sizeof(ntpmsg), which makes the check for a short packet always false.
Let's fix that by checking the actual size of the received data instead.

src/timesync/timesyncd-manager.c

index 79a9a629c14103e8640e0faf29d037163ec65966..e4f471e2aa5dcf65228e15d4d83dd2bf9ff7976b 100644 (file)
@@ -437,7 +437,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
         }
 
         /* Too short packet? */
-        if (iov.iov_len < sizeof(struct ntp_msg)) {
+        if ((size_t) len < sizeof(struct ntp_msg)) {
                 log_warning("Invalid response from server. Disconnecting.");
                 return manager_connect(m);
         }