On 01/23/15 03:06, Lennart Poettering wrote: > On Sun, 18.01.15 23:57, Topi Miettinen (toiwo...@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. -Topi > > (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@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/systemd-devel > > > Lennart > _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel