[systemd-devel] [PATCH] timesyncd: consider too long packets as invalid

David Herrmann dh.herrmann at gmail.com
Sun Jan 18 12:42:35 PST 2015


Hi

On Sun, Jan 18, 2015 at 3:01 PM, Topi Miettinen <toiwoton at gmail.com> wrote:
> 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.
> ---
>  src/timesync/timesyncd-manager.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Looks good, applied!

Thanks
David

> diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
> index 117ea8c..e183f96 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);
>          }
> --
> 2.1.4
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list