[systemd-devel] [PATCH] libudev: fix check for too long packet

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Fri Jan 23 09:38:29 PST 2015


On Fri, Jan 23, 2015 at 05:29:46PM +0000, Topi Miettinen wrote:
> On 01/23/15 03:06, Lennart Poettering wrote:
> > 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?
> 
> It doesn't work because the return value of recvmsg() never exceeds the
> buffer size, so too large packets are never detected.
It doesn't have to exceed the buffer size, it just has to equal it.
So packets of size sizeof(buf) and packets greater than that would
be detected as overlong. So the check wasn't wrong, just inefficient-by-one.

> > (The new check is much nicer though, admittedly)
Agreed.

Zbyszek


More information about the systemd-devel mailing list