<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ubus/lua, branch master</title>
<subtitle>OpenWrt system message/RPC bus</subtitle>
<id>https://git.openwrt.org/project/ubus/atom?h=master</id>
<link rel='self' href='https://git.openwrt.org/project/ubus/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/'/>
<updated>2026-09-25T07:46:40Z</updated>
<entry>
<title>ubus/lua: store event handler ref without polluting the callback table</title>
<updated>2026-09-25T07:46:40Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-07-17T20:00:41Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=414c60a2e29e72c2c4f573bc50ad54aef076d169'/>
<id>urn:sha1:414c60a2e29e72c2c4f573bc50ad54aef076d169</id>
<content type='text'>
ubus_lua_load_event() registered the listener via luaL_ref() into
__ubus_cb_event and then called

    lua_setfield(L, -1, lua_tostring(L, -3));

At that point index -1 is the __ubus_cb_event table itself and the
value on top of the stack is also that table, so the call assigned
__ubus_cb_event[&lt;event name&gt;] = __ubus_cb_event, a self-reference that
serves no purpose: event dispatch resolves the handler solely through
the integer luaL_ref stored in listener-&gt;r. Drop the bogus assignment
and just pop the table to keep the stack balanced.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>ubus/lua: copy the Lua strings stored in registered objects</title>
<updated>2026-09-25T07:46:40Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-07-17T19:25:41Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=fdd9ff1fe0fc1e0b0a97b072cce9e593c36b06c5'/>
<id>urn:sha1:fdd9ff1fe0fc1e0b0a97b072cce9e593c36b06c5</id>
<content type='text'>
Object name, type name and policy field names were stored as raw
lua_tostring() pointers into the caller's argument table. Once that table
is garbage-collected (the idiomatic case: the script does not retain it),
the backing strings are freed while the ubus_object/ubus_method
structures still reference them. libubus reads obj-&gt;name and the policy
names again when re-registering every object after a ubusd reconnect, and
obj-&gt;name is read on each incoming invoke (req.acl.object), so the freed
memory is used well after add(). Only method names survived, by accident,
because they double as keys in the persistent callback table. Keep owned
strdup() copies instead.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>ubus/lua: fix Lua stack imbalance on policy allocation failure</title>
<updated>2026-09-25T07:46:40Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-07-17T19:24:31Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=17525550a36b947dd7899d7adad91ee810e97126'/>
<id>urn:sha1:17525550a36b947dd7899d7adad91ee810e97126</id>
<content type='text'>
ubus_lua_load_methods() leaves the function pointer and policy table it
pushed on the Lua stack when the policy allocation fails, unlike the two
other exit paths which pop both. The caller only pops one value, so each
occurrence permanently unbalances the stack. Pop both before returning.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>lua: fix unchecked calloc and memory leak in ubus_lua_load_object</title>
<updated>2026-05-23T00:47:34Z</updated>
<author>
<name>Hauke Mehrtens</name>
</author>
<published>2026-04-12T22:11:26Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=43051ca73aec19c53d20e17e0e37a8ebd7d52d56'/>
<id>urn:sha1:43051ca73aec19c53d20e17e0e37a8ebd7d52d56</id>
<content type='text'>
Two bugs in the method array allocation:

1. calloc(mlen, sizeof(struct ubus_method)) was not checked for NULL.
   On OOM the returned NULL pointer was stored in obj-&gt;o.methods and
   later dereferenced as m[midx], causing a crash.

2. calloc(0, N) has implementation-defined behaviour (may return NULL
   or a unique pointer). Treat mlen == 0 explicitly by setting m = NULL
   and skipping the allocation.

3. When the subsequent calloc for obj-&gt;o.type failed, the already-
   allocated method array 'm' was not freed, causing a memory leak.

Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
Link: https://github.com/openwrt/ubus/pull/20
Signed-off-by: Hauke Mehrtens &lt;hauke@hauke-m.de&gt;
</content>
</entry>
<entry>
<title>lua: fix inverted argument check in ubus_lua_add</title>
<updated>2026-05-23T00:47:29Z</updated>
<author>
<name>Hauke Mehrtens</name>
</author>
<published>2026-04-12T22:10:57Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=3ab9d77595457f56ed1f26350ce15d308e50f09f'/>
<id>urn:sha1:3ab9d77595457f56ed1f26350ce15d308e50f09f</id>
<content type='text'>
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 &lt;noreply@anthropic.com&gt;
Link: https://github.com/openwrt/ubus/pull/20
Signed-off-by: Hauke Mehrtens &lt;hauke@hauke-m.de&gt;
</content>
</entry>
<entry>
<title>lua: CMakeLists: drop redundant cmake_minimum_required</title>
<updated>2025-10-07T12:19:11Z</updated>
<author>
<name>David Härdeman</name>
</author>
<published>2025-10-05T15:41:31Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=b462895d3157c0f2a87fb4a0341eead4202ce272'/>
<id>urn:sha1:b462895d3157c0f2a87fb4a0341eead4202ce272</id>
<content type='text'>
The Lua module depends on the parent ubus project and can't be built
independently.

Drop redundant cmake_minimum_required from lua/CMakeLists.txt and
inherit the version from the parent CMake project to keep version
consistency.

Signed-off-by: David Härdeman &lt;david@hardeman.nu&gt;
Link: https://github.com/openwrt/ubus/pull/7
Signed-off-by: Christian Marangi &lt;ansuelsmth@gmail.com&gt;
</content>
</entry>
<entry>
<title>lua: build: require CMake &gt;= 3.10 due to dropped legacy support</title>
<updated>2025-10-04T10:12:15Z</updated>
<author>
<name>Hauke Mehrtens</name>
</author>
<published>2025-10-03T17:49:29Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=ad2768bbc166b4dcb32665d7b3434d54150b2abc'/>
<id>urn:sha1:ad2768bbc166b4dcb32665d7b3434d54150b2abc</id>
<content type='text'>
CMake version 4.0 and later require minimum version of 3.5 or later.
Update to minimum version 3.10 which is the last not deprecated minimum
version.

CMake 3.10 was released in November 2017 and is included in Ubuntu 18.04.

Suggested-by: Hannu Nyman &lt;hannu.nyman@iki.fi&gt;
Signed-off-by: Hauke Mehrtens &lt;hauke@hauke-m.de&gt;
</content>
</entry>
<entry>
<title>lua: add optional path filter to objects() method</title>
<updated>2022-05-30T05:00:52Z</updated>
<author>
<name>Etienne Champetier</name>
</author>
<published>2022-05-01T21:58:09Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=2f793a4eb063128d80fc46ada243d2aad47fd1fe'/>
<id>urn:sha1:2f793a4eb063128d80fc46ada243d2aad47fd1fe</id>
<content type='text'>
'ubus list [&lt;path&gt;]' passes the path to ubusd,
this commit fix the lua bindings to do the same

Signed-off-by: Etienne Champetier &lt;champetier.etienne@gmail.com&gt;
</content>
</entry>
<entry>
<title>lua: avoid truncation of large numeric values</title>
<updated>2020-03-15T19:49:27Z</updated>
<author>
<name>Alin Nastac</name>
</author>
<published>2020-02-03T12:58:04Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=171469e3138cce191892e20b6fd35b52c9368064'/>
<id>urn:sha1:171469e3138cce191892e20b6fd35b52c9368064</id>
<content type='text'>
If the Lua number exceeds the maximum value representable by an
unsigned 32bit integer, store it in an unsigned 64bit integer
field instead.

Signed-off-by: Alin Nastac &lt;alin.nastac@gmail.com&gt;
[align code style, reword commit message]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>lua: ubus_lua_do_subscribe: fix copy&amp;paste error</title>
<updated>2019-12-16T22:39:16Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2019-12-16T22:02:02Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ubus/commit/?id=72be8e93f07d0dfb1f42edfbdb93ea04311dcb5a'/>
<id>urn:sha1:72be8e93f07d0dfb1f42edfbdb93ea04311dcb5a</id>
<content type='text'>
Fix copy&amp;paste error in Lua ubus subscriber removal callback.

Addresses-Coverity-ID: 1412311 ("Copy-paste error")
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
</feed>
