]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: Complain if setting O_NONBLOCK fails
authorPhil Sutter <phil@nwl.cc>
Thu, 1 Mar 2018 14:00:31 +0000 (15:00 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 2 Mar 2018 10:46:56 +0000 (11:46 +0100)
Assuming that code is not aware that reads from netlink socket may
block, treat inability to set O_NONBLOCK flag as fatal initialization
error aborting program execution.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink.c

index c7adf8b409c69ce0b3b7e3ab7e9d3167a4750178..06b1f57ae1948e81a83e50a062d47dc9c9d653f6 100644 (file)
@@ -59,7 +59,8 @@ struct mnl_socket *netlink_open_sock(void)
        if (nf_sock == NULL)
                netlink_init_error();
 
-       fcntl(mnl_socket_get_fd(nf_sock), F_SETFL, O_NONBLOCK);
+       if (fcntl(mnl_socket_get_fd(nf_sock), F_SETFL, O_NONBLOCK))
+               netlink_init_error();
 
        return nf_sock;
 }