From: Lennart Poettering Date: Mon, 1 Feb 2016 21:17:35 +0000 (+0100) Subject: sd-netlink: since whe acquire the netlink socket's sockaddr anyway, let's actually... X-Git-Tag: v231~691^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6c16624bf417be67d62bbf53fa19d3ea44eaf5a;p=platform%2Fupstream%2Fsystemd.git sd-netlink: since whe acquire the netlink socket's sockaddr anyway, let's actually verify it --- diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index ab42b96..d3eb379 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -44,11 +44,8 @@ static int sd_netlink_new(sd_netlink **ret) { return -ENOMEM; rtnl->n_ref = REFCNT_INIT; - rtnl->fd = -1; - rtnl->sockaddr.nl.nl_family = AF_NETLINK; - rtnl->original_pid = getpid(); LIST_HEAD_INIT(rtnl->match_callbacks); @@ -87,6 +84,9 @@ int sd_netlink_new_from_netlink(sd_netlink **ret, int fd) { if (r < 0) return -errno; + if (rtnl->sockaddr.nl.nl_family != AF_NETLINK) + return -EINVAL; + rtnl->fd = fd; *ret = rtnl;