]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lua: fix coverity unchecked return
authorJason Ish <jason.ish@oisf.net>
Mon, 2 Jun 2025 15:07:20 +0000 (09:07 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 4 Jun 2025 07:39:51 +0000 (09:39 +0200)
CID 1648351: (#1 of 1): Unchecked return value (CHECKED_RETURN)
1. check_return: Calling lua_getstack without checking return value (as is done elsewhere 9 out of 10 times).

src/util-lua-sandbox.c

index ffe8e5b5adc82806ec50647e81504ec7e1dbeab1..7dc532b6bc0c298e47338280bdb44abef5bc90aa 100644 (file)
@@ -31,6 +31,7 @@
 #include "util-debug.h"
 #include "util-lua-sandbox.h"
 #include "util-lua-builtins.h"
+#include "util-validate.h"
 
 #define SANDBOX_CTX "SANDBOX_CTX"
 
@@ -101,13 +102,13 @@ static int LuaBlockedFunction(lua_State *L)
     SCLuaSbState *context = SCLuaSbGetContext(L);
     context->blocked_function_error = true;
     lua_Debug ar;
-    lua_getstack(L, 0, &ar);
-    lua_getinfo(L, "n", &ar);
-    if (ar.name) {
+    if (lua_getstack(L, 0, &ar) && lua_getinfo(L, "n", &ar) && ar.name) {
         luaL_error(L, "Blocked Lua function called: %s", ar.name);
     } else {
         luaL_error(L, "Blocked Lua function: name not available");
     }
+    /* never reached */
+    DEBUG_VALIDATE_BUG_ON(1);
     return -1;
 }