uci: fix a potential use-after-free in uci_set() When calling uci_set() to update an option, if ptr->o != NULL and ptr->option == NULL, then uci_expand_ptr() will set ptr->option to ptr->o->e.name (or the caller could set ptr->option to that value). In this case, the option will be freed just before calling uci_alloc_option() with ptr->option, which was just freed. Signed-off-by: Jordan Miner <jminer7@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
cmake: Fix cli shared linking against ubox The 'ubox' library used in 'cli' target is not using the output of the 'find_library' command. This is a problem when the 'ubox' library is not located on the standard system library locations. Use the CMake variable 'ubox', output of 'find_library' call that points to the library found on the system, instead of hardcoding the library's name to 'ubox'. Signed-off-by: Andre Castro <andre.castro.sw@gmail.com>
lua: additionally return name when looking up sections Return the resolved name in addition to the type when looking up sections through `get()` - for example a `cursor:get("firewall", "@rule[0]")` will now return two values in the form ("rule", "cfg0a92bd") instead of only the type name. This is mainly useful to resolve extended section names without having to reimplement the section count logic in Lua code. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
lua: support extended section notation Wrap uci_lookup_ptr() to enable extended section format lookups when the passed section literal is in "@" notation. This allows calls in the form `cursor:get("conf", "@stype[0]", "opt")` which is useful to resolve options in numerically indexed anonymous sections. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
file: remove unnecessary uci_fixup_section calls This makes it clear uci_fixup_section only needs to be called in uci_add_section when an unnamed section is added. Before it was a bit misleading when walking through the code seeing uci_fixup_section being called in uci_parse_config and uci_import. When uci config is parsed via these functions uci_add_section is eventually called which in the end constructs a name for an unnamed section. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Revert "mandatory anonymous section identifier" This reverts commits: df72af474075 "mandatory anonymous section identifier" 2eb9c097e392 "cli: remove now-defunct UCI_FLAG_EXPORT_NAME support" fe45f97302cb "test: adjust for auto-naming anonymous sections" After some discussion we came to the conclusion that we need a different fix. Signed-off-by: Felix Fietkau <nbd@nbd.name>
mandatory anonymous section identifier This change makes sure there are no more anonymous (unnamed) sections in configuration files. Previously it was optional and now the choice is being removed. All sections will have generated identifiers. This is important because anonymous sections will be simpler to manipulate. Signed-off-by: Antonio Paunovic <antonio.paunovic@sartura.hr> Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
projects/uci: lua: use built in pkg-config support for alternatives Different distributions have different names for the lua 5.1 package. Use cmake's built in pkg-config support to search for the first one, rather than running it explicitly and searching for a single version. Signed-off-by: Karl Palsson <karlp@remake.is>