diff options
author | Christoph Lohmann <20h@r-36.net> | 2012-04-28 11:13:07 +0200 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2012-04-28 11:13:07 +0200 |
commit | 4671d8270e28dca692eec5cef1bb533a423cf1dc (patch) | |
tree | d6124bd9119df53a22c82deca003ba6c84eabf97 /nldev.c | |
parent | e2d4a797b6364fd79fc6102d866f074409604815 (diff) | |
download | nldev-4671d8270e28dca692eec5cef1bb533a423cf1dc.tar.bz2 nldev-4671d8270e28dca692eec5cef1bb533a423cf1dc.tar.xz |
Message error handling fixed at nl_pid and EINTR.
Diffstat (limited to 'nldev.c')
-rw-r--r-- | nldev.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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; } |