[systemd-devel] [PATCH] libudev: fix check for too long packet
Lennart Poettering
lennart at poettering.net
Thu Jan 22 19:06:29 PST 2015
On Sun, 18.01.15 23:57, Topi Miettinen (toiwoton at gmail.com) wrote:
> Don't use recvmsg(2) return value to check for too long packets
> (it doesn't work) but MSG_TRUNC flag.
Why precisely doesn't this work? I mean, it will consider messages
that are exactly as large as the buffer as too long, but otherwise the
old check should be fine, no?
(The new check is much nicer though, admittedly)
> ---
> src/libudev/libudev-monitor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
> index 484fefe..d8e551b 100644
> --- a/src/libudev/libudev-monitor.c
> +++ b/src/libudev/libudev-monitor.c
> @@ -609,7 +609,7 @@ retry:
> return NULL;
> }
>
> - if (buflen < 32 || (size_t)buflen >= sizeof(buf)) {
> + if (buflen < 32 || smsg.msg_flags & MSG_TRUNC) {
> log_debug("invalid message length");
> return NULL;
> }
> --
> 2.1.4
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list