summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-netlink
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-01 22:17:35 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-01 22:18:16 +0100
commitd6c16624bf417be67d62bbf53fa19d3ea44eaf5a (patch)
treed8292634391a1d863ad02bedcd5c7c7564fed591 /src/libsystemd/sd-netlink
parentsd-netlink: don't take possesion of netlink fd from caller on failure (diff)
downloadsystemd-d6c16624bf417be67d62bbf53fa19d3ea44eaf5a.tar.xz
systemd-d6c16624bf417be67d62bbf53fa19d3ea44eaf5a.zip
sd-netlink: since whe acquire the netlink socket's sockaddr anyway, let's actually verify it
Diffstat (limited to 'src/libsystemd/sd-netlink')
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index ab42b96a2e..d3eb379c9a 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;