timesync: verify the actual size of the received data
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.
This commit is contained in:
committed by
Luca Boccassi
parent
0112338585
commit
335cc8f39c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user