summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-05-31 16:17:42 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-05-31 18:07:25 +0200
commit59d301ec80264a907918028c590f7f172003a995 (patch)
treecdfa772d31a3eb98e46def8e8bc299d24b91730b /src
parent9c92b22d04ba74be89fd2b49896e079c0980ed2d (diff)
mnl: Initialize fd_set before select(), not after
Calling FD_SET() in between return of select() and call to FD_ISSET() effectively renders the whole thing useless: FD_ISSET() will always return true no matter what select() actually did. Fixes: a72315d2bad47 ("src: add rule batching support") Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/mnl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mnl.c b/src/mnl.c
index 4eba2789..b32e4190 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -349,12 +349,12 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list,
if (ret == -1)
mnl_err_list_node_add(err_list, errno, nlh->nlmsg_seq);
+ FD_ZERO(&readfds);
+ FD_SET(fd, &readfds);
+
ret = select(fd+1, &readfds, NULL, NULL, &tv);
if (ret == -1)
return -1;
-
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
}
return 0;
}