From 3ca189cdd763ffa0acd702c5099c0f4f010a5347 Mon Sep 17 00:00:00 2001 From: Ademiju Adewole Date: Sat, 18 Apr 2026 23:20:14 +0100 Subject: [PATCH] fix: add validation to luv_parse_signal Adds validation of signals passed as strings to luv_parse_signal, and transitively to luv_process_kill and luv_kill. The previous behavior was to swallow errors from invalid signals. --- src/process.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/process.c b/src/process.c index 127be3d1..0d10375d 100644 --- a/src/process.c +++ b/src/process.c @@ -115,7 +115,7 @@ static int luv_spawn(lua_State* L) { // collected between now and when they are used in uv_spawn. // However, we don't need to ref args[0] since we don't pop that // from the stack. Note: args_refs is a LUA_NOREF-terminated array - // when it is non-NULL + // when it is non-NULL if (len > 1) { args_refs = (int*)malloc(len * sizeof(int)); if (args_refs) @@ -309,7 +309,9 @@ static int luv_parse_signal(lua_State* L, int slot) { return lua_tonumber(L, slot); } if (lua_isstring(L, slot)) { - return luv_sig_string_to_num(lua_tostring(L, slot)); + int signum = luv_sig_string_to_num(lua_tostring(L, slot)); + luaL_argcheck(L, signum, slot, "Invalid Signal name"); + return signum; } return SIGTERM; }