Browse Source

Ensure proper Netlink initialization

Make sure the netlink message is properly zeroed and that the
needed members are filled in.

Thanks to "neologix" from linuxfr.org.
develop
Damien Goutte-Gattat 8 years ago
parent
commit
d496639b00
  1. 3
      src/wait4pid.c

3
src/wait4pid.c

@ -43,6 +43,8 @@ set_proc_listen(int sock, int enable)
} *payload;
char buf[NLMSG_SPACE(sizeof(struct payload_t))];
memset(buf, 0, sizeof(buf));
hdr = (struct nlmsghdr *)buf;
hdr->nlmsg_type = NLMSG_DONE;
hdr->nlmsg_flags = NLM_F_REQUEST;
@ -52,6 +54,7 @@ set_proc_listen(int sock, int enable)
payload = (struct payload_t *) NLMSG_DATA(hdr);
payload->msg.id.idx = CN_IDX_PROC;
payload->msg.id.val = CN_VAL_PROC;
payload->msg.len = sizeof(payload->op);
payload->op = enable ? PROC_CN_MCAST_LISTEN : PROC_CN_MCAST_IGNORE;
return send(sock, hdr, NLMSG_SPACE(sizeof(*payload)), 0);

Loading…
Cancel
Save