aboutgitcodelistschat:MatrixIRC
path: root/seitan.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-11-03 14:16:05 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-11-03 14:16:05 +0100
commita7aef7ef4f74e1155833c9abcf3720be40092282 (patch)
treefe75231205b391b88d436bf1c323e59710205ed2 /seitan.c
parent36b8eb3ce55602bcf36199330e98f2e154225cf7 (diff)
downloadseitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar.gz
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar.bz2
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar.lz
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar.xz
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.tar.zst
seitan-a7aef7ef4f74e1155833c9abcf3720be40092282.zip
seitan: Read the rest of the netlink message on event mismatch
...the PROC_EVENT_EXEC we're looking for might be hiding there. Also, avoid a possible endless loop on NLMSG_NOOP. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'seitan.c')
-rw-r--r--seitan.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/seitan.c b/seitan.c
index bc98aed..d1e55a6 100644
--- a/seitan.c
+++ b/seitan.c
@@ -74,9 +74,10 @@ static int event(int s)
return -EIO;
nlh = (struct nlmsghdr *)buf;
- while (NLMSG_OK(nlh, n)) {
+ for (; NLMSG_OK(nlh, n); nlh = NLMSG_NEXT(nlh, n)) {
if (nlh->nlmsg_type == NLMSG_NOOP)
continue;
+
if ((nlh->nlmsg_type == NLMSG_ERROR) ||
(nlh->nlmsg_type == NLMSG_OVERRUN))
break;
@@ -85,7 +86,7 @@ static int event(int s)
ev = (struct proc_event *)cnh->data;
if (ev->what != PROC_EVENT_EXEC)
- return -EAGAIN;
+ continue;
snprintf(path, PATH_MAX, "/proc/%i/exe",
ev->event_data.exec.process_pid);
@@ -97,8 +98,6 @@ static int event(int s)
if (nlh->nlmsg_type == NLMSG_DONE)
break;
-
- nlh = NLMSG_NEXT(nlh, n);
}
return -EAGAIN;