[PATCH uci] file: Fix uci -m import command

Jan Venekamp jan at venekamp.net
Fri Jul 14 11:35:45 PDT 2023


On 13/07/2023 18:53, Hauke Mehrtens wrote:
> Without this change we see the following error:
>    # uci -m import optic < /etc/optic-db/default
>    uci: Parse error (option/list command found before the first section) at line 4, byte 1
>
> ptr.last is still a null pointer in case the uci_lookup_list() call
> found a matching section and set ptr.s to it. The code expects that
> uci_set() updates the ptr.last pointer, but this is not done any more

Ah snap, I overlooked that in uci_parse_config while working on uci_set.

A clearer fix might be to just change the last line of uci_parse_config to:
pctx->section = ptr.s;
The change to uci_parse_option does not do anything, ptr->last is never 
read after being set.

However, seeing this made me more convinced that ptr.last just 
complicates the code while being redundant anyway. So I created a patch 
that removes internal usage of ptr.last altogether. Would you please be 
so kind to take a look at it?
https://patchwork.ozlabs.org/project/openwrt/list/?series=363985

While your at it, maybe you could also take a look at these other 
patches for uci?
https://patchwork.ozlabs.org/project/openwrt/patch/20221120010927.23856-2-jan@venekamp.net/
https://patchwork.ozlabs.org/project/openwrt/patch/SY4P282MB39395204AE37BC45D35D834CC57B9@SY4P282MB3939.AUSP282.PROD.OUTLOOK.COM/

Kind regards,
Jan Venekamp




More information about the openwrt-devel mailing list