[PATCH uci] uci: decrease the n_section when section is freed

Jan Venekamp jan at venekamp.net
Thu Sep 14 15:53:23 PDT 2023


On 14/09/2023 23:36, Leon Busch-George wrote:
> Before finding and applying Jeff's patch I had written a small test
> application that creates a few random sections in the 'dhcp' UCI
> package and deletes them again (uci_set).
> Afterwards, it iterates all packages (uci_list_configs), prints a line
> if there is a delta (ptr.p->has_delta), and calls uci_save.
> Basically, there were erroneous 'has_delta' entries for all packages.

The bool package->has_delta is used by libuci to determine whether to
use "delta tracking". This value is set to true for every package that
is loaded from a file within confdir (default: /etc/config),
see uci_load() -> uci_file_load(). So yeah, if you loaded the packages
from within /etc/config it would be true for every package.

> If enough sections were created and deleted, I would reliably segfault
> when iterating sections (e.g.
> uci_foreach_element_safe(&u_ptr.p->sections, tmp, e)).
> That is how I discovered the bug.

I am very curious as to how Jeff's patch helps with that, because the
package->n_section value is only used to auto-create a name for
anonymous sections.

> I abandonded and deleted the test app and the report since, at least
> to me, Jeff's patch appears to be a valid solution.
> If you want, I could recreate it. Let me know!

Please do. If you could provide example code, I will gladly take a
look at it.



More information about the openwrt-devel mailing list