aboutsummaryrefslogtreecommitdiffstats
path: root/nldev.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-04-28 11:13:07 +0200
committerChristoph Lohmann <20h@r-36.net>2012-04-28 11:13:07 +0200
commit4671d8270e28dca692eec5cef1bb533a423cf1dc (patch)
treed6124bd9119df53a22c82deca003ba6c84eabf97 /nldev.c
parente2d4a797b6364fd79fc6102d866f074409604815 (diff)
downloadnldev-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.c16
1 files 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;
}