From 4671d8270e28dca692eec5cef1bb533a423cf1dc Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 28 Apr 2012 11:13:07 +0200 Subject: Message error handling fixed at nl_pid and EINTR. --- nldev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nldev.c b/nldev.c index 9801056..3cf661c 100644 --- a/nldev.c +++ b/nldev.c @@ -254,19 +254,18 @@ main(int argc, char *argv[]) hdr.msg_name = &cnls; hdr.msg_namelen = sizeof(cnls); - printf("recvmsg\n"); len = recvmsg(fds.fd, &hdr, 0); - if (len < 0 && errno == EINTR) - continue; - printf("check 2\n"); + if (len < 0) { + if (errno == EINTR) + continue; + edie("recvmsg"); + } if (len < 32 || len >= sizeof(buf)) - edie("recv"); + continue; - printf("chdr\n"); chdr = CMSG_FIRSTHDR(&hdr); if (chdr == NULL || chdr->cmsg_type != SCM_CREDENTIALS) continue; - printf("cred\n"); /* * Don't allow anyone but root to send us messages. @@ -279,7 +278,6 @@ main(int argc, char *argv[]) if (cred->uid != 0 && !showudev) continue; - printf("libudev\n"); if (!memcmp(buf, "libudev", 8)) { /* * Receiving messages from udev is insecure. @@ -293,7 +291,7 @@ main(int argc, char *argv[]) * Kernel messages shouldn't come from the * userspace. */ - if (cnls.pid > 0) + if (cnls.nl_pid > 0) continue; } -- cgit v1.2.3