chiark / gitweb /
timesyncd: consider too long packets as invalid
authorTopi Miettinen <toiwoton@gmail.com>
Sun, 18 Jan 2015 14:01:25 +0000 (16:01 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Sun, 18 Jan 2015 20:42:00 +0000 (21:42 +0100)
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)

src/timesync/timesyncd-manager.c

index 117ea8c98d83c495edb043e566951a5a7f25603f..bc35662481fb5d4b958cc929666c72a3e71ca5f9 100644 (file)
@@ -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);
         }