From: Grigorii Demidov Date: Tue, 11 Dec 2018 14:57:57 +0000 (+0100) Subject: daemon/bindings: eBPF socket filters bindings, avoid usage of lua 5.3 macro; fix... X-Git-Tag: v3.2.0~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e25e805f6a61428d1aeb1fc42a239f416aef987;p=thirdparty%2Fknot-resolver.git daemon/bindings: eBPF socket filters bindings, avoid usage of lua 5.3 macro; fix clang warnings --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 271c52882..917943e1e 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -882,11 +882,10 @@ static int net_tls_handshake_timeout(lua_State *L) static int net_bpf_set(lua_State *L) { - int ret; struct engine *engine = engine_luaget(L); struct network *net = &engine->net; - if (lua_gettop(L) != 1 || lua_type(L, 1) != LUA_TINTEGER) { + if (lua_gettop(L) != 1 || !lua_isnumber(L, 1)) { format_error(L, "net.bpf_set(fd) takes one parameter: the open file descriptor of a loaded BPF program"); lua_error(L); return 0; @@ -895,6 +894,13 @@ static int net_bpf_set(lua_State *L) #if __linux__ int progfd = lua_tointeger(L, 1); + if (progfd == 0) { + /* conversion error despite that fact + * that lua_isnumber(L, 1) has returned true. + * Real or stdin? */ + lua_error(L); + return 0; + } lua_pop(L, 1); if (!network_set_bpf(net, progfd)) { @@ -917,7 +923,6 @@ static int net_bpf_set(lua_State *L) static int net_bpf_clear(lua_State *L) { - int ret; struct engine *engine = engine_luaget(L); struct network *net = &engine->net;