summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Miettinen <toiwoton@gmail.com>2015-01-18 16:01:25 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-01-18 21:42:00 +0100
commit43fcd650e5cb0836cfc9f667ed74b3bc0283a81c (patch)
treea5fed885d973277241400a59955acaaad6dcf5b2
parent50efadb0ae7bcb4fc5ce5e41163c697501ca1d50 (diff)
timesyncd: consider too long packets as invalid
If the received NTP message from server didn't fit to our buffer, either it is doing something nasty or we don't know the protocol. Consider the packet as invalid. (David: add parantheses around conditional)
-rw-r--r--src/timesync/timesyncd-manager.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 117ea8c98d..bc35662481 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -525,7 +525,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
return manager_connect(m);
}
- if (iov.iov_len < sizeof(struct ntp_msg)) {
+ /* Too short or too long packet? */
+ if (iov.iov_len < sizeof(struct ntp_msg) || (msghdr.msg_flags & MSG_TRUNC)) {
log_warning("Invalid response from server. Disconnecting.");
return manager_connect(m);
}