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

Topi Miettinen toiwoton at gmail.com
Fri Jan 23 10:01:12 PST 2015


On 01/23/15 17:43, Lennart Poettering wrote:
> On Fri, 23.01.15 17:29, Topi Miettinen (toiwoton at gmail.com) 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.
> 
> But the test was ">=", not ">". So the old code *did* recognize all
> too large packets, though it would already do so one byte earlier than
> your new check...

True. What should be considered too large, a full buffer (which might
not contain a trailing zero, so the strcmp later could fall off of the
buffer...), or buffer size - 1 (the last byte is not explicitly set to
zero, so badness could happen anyway)?

-Topi

> 
> Lennart
> 



More information about the systemd-devel mailing list