diff options
| author | Hauke Mehrtens | 2026-04-12 22:10:57 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-05-23 00:47:29 +0000 |
| commit | 3ab9d77595457f56ed1f26350ce15d308e50f09f (patch) | |
| tree | e8ea908ecabdb976e1f5e4885fe5698eda36f351 | |
| parent | 7ecacfadd9bca05fae69690207c11ab894489e3f (diff) | |
| download | ubus-3ab9d77595457f56ed1f26350ce15d308e50f09f.tar.gz | |
lua: fix inverted argument check in ubus_lua_add
The guard 'if (lua_istable(L, 1))' was backwards: it raised an error
when argument 1 IS a table, but argument 1 is always the ubus_context
userdata (never a table). The intent was to reject calls where argument
2 is NOT a table.
As a result, any call to ubus.add(c, non_table) silently proceeded to
lua_next() on a non-table value, causing a crash, while a valid call
with a proper table as argument 2 was never incorrectly rejected only
because arg 1 never matches lua_istable.
Fix by checking !lua_istable(L, 2).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Link: https://github.com/openwrt/ubus/pull/20
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | lua/ubus.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -559,7 +559,7 @@ static int ubus_lua_add(lua_State *L) struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); /* verify top level object */ - if (lua_istable(L, 1)) { + if (!lua_istable(L, 2)) { lua_pushstring(L, "you need to pass a table"); return lua_error(L); } |