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

2023-09-14 Thread Jan Venekamp
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

[PATCH uci] reduce code complexity of uci_show_package

2023-09-08 Thread Jan Venekamp
s the code complexity of uci_show_package, uci_show_section and uci_show_option. Signed-off-by: Jan Venekamp --- cli.c | 132 +- .../references/show_parsing_multiline.data| 3 + .../show_parsing_multiline_package.result | 2 + 3 fil

Re: [PATCH netifd] system-linux: Do not unconditionally activate IPv6 on devices

2023-09-07 Thread Jan Venekamp
I overlooked this patch when submitting [1]. Slightly different argumentation, exact same conclusion. Hauke can you apply this? Kind regards, Jan Venekamp [1] https://patchwork.ozlabs.org/project/openwrt/patch/20230626193755.25155-1-...@venekamp.net/ Reviewed-by: Jan Venekamp

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

2023-09-07 Thread Jan Venekamp
this behaviour? Kind regards, Jan Venekamp [1] https://git.openwrt.org/?p=project/uci.git;a=commitdiff;h=16e8a3b1 --- .../references/batch_anonymous_section.result | 7 +++ tests/shunit2/tests.d/060_batch | 17 + 2 files changed, 24 insertions(+) create mo

Re: [PATCH uci 2/2] remove internal usage of redundant uci_ptr.last

2023-08-01 Thread Jan Venekamp
On 01/08/2023 22:27, Hauke Mehrtens wrote: On 7/14/23 20:28, Jan Venekamp wrote: In uci_lookup_ptr and uci_set the pointer uci_ptr ptr.last is set to the element corresponding to the first of: ptr.o, ptr.s, ptr.p. Thus, ptr.last is redundant and in case of uci_set is (and was) not always

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

2023-07-14 Thread Jan Venekamp
ekamp.net/ https://patchwork.ozlabs.org/project/openwrt/patch/sy4p282mb39395204ae37bc45d35d834cc5...@sy4p282mb3939.ausp282.prod.outlook.com/ Kind regards, Jan Venekamp ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.or

[PATCH uci 2/2] remove internal usage of redundant uci_ptr.last

2023-07-14 Thread Jan Venekamp
ptr.last in uci_lookup_ptr intact. Signed-off-by: Jan Venekamp --- cli.c | 39 +++ delta.c | 10 ++ list.c| 6 -- lua/uci.c | 42 +++--- 4 files changed, 32 insertions(+), 65 deletions(-) diff --git a

[PATCH uci 0/2] remove internal usage of redundant uci_ptr.last

2023-07-14 Thread Jan Venekamp
Remove internal usage of redundant uci_ptr.last in order to fix issue and simplify code. Jan Venekamp (2): file: Fix uci -m import command remove internal usage of redundant uci_ptr.last cli.c | 39 +++ delta.c | 10 ++ file.c| 2

[PATCH uci 1/2] file: Fix uci -m import command

2023-07-14 Thread Jan Venekamp
) Co-authored-by: Hauke Mehrtens Signed-off-by: Jan Venekamp --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index 93abfae..6610f53 100644 --- a/file.c +++ b/file.c @@ -459,7 +459,7 @@ static void uci_parse_config(struct uci_context *ctx)

[PATCH] netifd: Do not set disable_ipv6=0 in system_if_clear_state()

2023-06-26 Thread Jan Venekamp
[1] https://git.openwrt.org/?p=project/netifd.git;a=commitdiff;h=53f8ed2c [2] https://git.openwrt.org/?p=project/netifd.git;a=commitdiff;h=98ca6746 Signed-off-by: Jan Venekamp --- system-linux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/system-linux.c b/system-linux.c index 0760e73..4cfd95b 10

[PATCH 1/1] uci: ignore wrong section / option name in uci_ptr

2022-11-19 Thread Jan Venekamp
option and in the case of uci_revert. In other cases use ptr->s->e.name and ptr->o->e.name exclusively. Signed-off-by: Jan Venekamp --- list.c | 61 -- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/list.c b/l

[PATCH 0/1] uci: ignore wrong section / option name in uci_ptr

2022-11-19 Thread Jan Venekamp
This patch depends on patch series: [PATCH v2] uci: fixes for uci_set and uci_add_list Jan Venekamp (1): uci: ignore wrong section / option name in uci_ptr list.c | 61 -- 1 file changed, 25 insertions(+), 36 deletions(-) -- 2.32.0

[PATCH v2 7/9] uci: fix memory leak uci_set on update section

2022-11-19 Thread Jan Venekamp
ating an option. Signed-off-by: Jan Venekamp --- list.c | 62 +++--- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/list.c b/list.c index e6d631c..3e8a87c 100644 --- a/list.c +++ b/list.c @@ -30,12 +30,6 @@ static bool uci_list

[PATCH v2 9/9] uci: macro uci_alloc_element not in uci.h

2022-11-19 Thread Jan Venekamp
The macro uci_alloc_element is in the public header file uci.h. However, the macros output refers to uci_alloc_generic wich is in uci_internal.h and not public. Thus, uci_alloc_element should be private as well and moved to uci_internal.h. Signed-off-by: Jan Venekamp --- uci.h | 10

[PATCH v2 5/9] uci: fix atomicity of uci_add_list

2022-11-19 Thread Jan Venekamp
The function uci_add_list is not atomic, when an alloc inside uci_add_element_list fails the option can be left in an indeterminate state. Refactor uci_add_list to fix this and make the code flow easier to read. Signed-off-by: Jan Venekamp --- list.c | 74

[PATCH v2 0/9] uci: fixes for uci_set and uci_add_list

2022-11-19 Thread Jan Venekamp
issues as well as some other improvements. Jan Venekamp (9): uci: fix use-after-free uci_set on update option uci: maintain option position in uci_set uci: optimize update option in uci_set uci: fix use-after-free uci_add_list uci: fix atomicity of uci_add_list uci: maintain option position

[PATCH v2 8/9] uci: optimize update section in uci_set

2022-11-19 Thread Jan Venekamp
Optimize for the case when there is no need to update the section and the case there is no need to reallocate memory when updating a section in uci_set. Signed-off-by: Jan Venekamp --- list.c| 23 +++ tests/shunit2/tests.d/090_cli_options | 8

[PATCH v2 6/9] uci: maintain option position in uci_add_list

2022-11-19 Thread Jan Venekamp
Maintain the position of an option in the list when a string option is converted to a list option in uci_add_list. Signed-off-by: Jan Venekamp --- list.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/list.c b/list.c index 3518967..e6d631c 100644 --- a/list.c +++ b

[PATCH v2 4/9] uci: fix use-after-free uci_add_list

2022-11-19 Thread Jan Venekamp
he call to uci_add_delta in uci_add_element_list after uci_free_option(prev). Signed-off-by: Jan Venekamp --- list.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/list.c b/list.c index 5148dfd..ba099b6 100644 --- a/list.c +++ b/list.c @@ -652,6 +652,8 @@ int uci_add_list(struct uci_context

[PATCH v2 2/9] uci: maintain option position in uci_set

2022-11-19 Thread Jan Venekamp
Maintain the position of an option in the list when updating an option in uci_set. Signed-off-by: Jan Venekamp --- list.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/list.c b/list.c index ac3686c..a8f2a2c 100644 --- a/list.c +++ b/list.c @@ -76,7 +76,7

[PATCH v2 1/9] uci: fix use-after-free uci_set on update option

2022-11-19 Thread Jan Venekamp
When uci_set is called with ptr->o set and ptr->option = NULL, then in uci_expand_ptr ptr->option is set to ptr->o->e.name. This will result in use-after-free because ptr->option is used in the call to uci_add_delta after uci_free_option(ptr->o). Signed-off-by: Jan Vene

[PATCH v2 3/9] uci: optimize update option in uci_set

2022-11-19 Thread Jan Venekamp
Optimize for the case when there is no need to reallocate memory when updating an option in uci_set. Signed-off-by: Jan Venekamp --- list.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/list.c b/list.c index a8f2a2c..5148dfd 100644 --- a/list.c +++ b

[PATCH 9/9] uci: macro uci_alloc_element not in uci.h

2022-08-16 Thread Jan Venekamp
The macro uci_alloc_element is in the public header file uci.h. However, the macros output refers to uci_alloc_generic wich is in uci_internal.h and not public. Thus, uci_alloc_element should be private as well and moved to uci_internal.h. Signed-off-by: Jan Venekamp --- uci.h | 10

[PATCH 8/9] uci: optimize update section in uci_set

2022-08-16 Thread Jan Venekamp
Optimize for the case when there is no need to update the section and the case there is no need to reallocate memory when updating a section in uci_set. Signed-off-by: Jan Venekamp --- list.c| 23 +++ tests/shunit2/tests.d/090_cli_options | 8

[PATCH 7/9] uci: fix memory leak uci_set on update section

2022-08-16 Thread Jan Venekamp
ating an option. Signed-off-by: Jan Venekamp --- list.c | 62 +++--- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/list.c b/list.c index e6d631c..783836b 100644 --- a/list.c +++ b/list.c @@ -30,12 +30,6 @@ static bool uci_list

[PATCH 5/9] uci: fix atomicity of uci_add_list

2022-08-16 Thread Jan Venekamp
The function uci_add_list is not atomic, when an alloc inside uci_add_element_list fails the option can be left in an indeterminate state. Refactor uci_add_list to fix this and make the code flow easier to read. Signed-off-by: Jan Venekamp --- list.c | 74

[PATCH 6/9] uci: maintain option position in uci_add_list

2022-08-16 Thread Jan Venekamp
Maintain the position of an option in the list when a string option is converted to a list option in uci_add_list. Signed-off-by: Jan Venekamp --- list.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/list.c b/list.c index 3518967..e6d631c 100644 --- a/list.c +++ b

[PATCH 2/9] uci: maintain option position in uci_set

2022-08-16 Thread Jan Venekamp
Maintain the position of an option in the list when updating an option in uci_set. Signed-off-by: Jan Venekamp --- list.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/list.c b/list.c index ac3686c..a8f2a2c 100644 --- a/list.c +++ b/list.c @@ -76,7 +76,7

[PATCH 4/9] uci: fix use-after-free uci_add_list

2022-08-16 Thread Jan Venekamp
he call to uci_add_delta in uci_add_element_list after uci_free_option(prev). Signed-off-by: Jan Venekamp --- list.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/list.c b/list.c index 5148dfd..ba099b6 100644 --- a/list.c +++ b/list.c @@ -652,6 +652,8 @@ int uci_add_list(struct uci_context

[PATCH 3/9] uci: optimize update option in uci_set

2022-08-16 Thread Jan Venekamp
Optimize for the case when there is no need to reallocate memory when updating an option in uci_set. Signed-off-by: Jan Venekamp --- list.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/list.c b/list.c index a8f2a2c..5148dfd 100644 --- a/list.c +++ b

[PATCH 1/9] uci: fix use-after-free uci_set on update option

2022-08-16 Thread Jan Venekamp
When uci_set is called with ptr->o set and ptr->option = NULL, then in uci_expand_ptr ptr->option is set to ptr->o->e.name. This will result in use-after-free because ptr->option is used in the call to uci_add_delta after uci_free_option(ptr->o). Signed-off-by: Jan Vene

[PATCH 0/9] uci: fixes for uci_set and uci_add_list

2022-08-16 Thread Jan Venekamp
issues as well as some other improvements. Jan Venekamp (9): uci: fix use-after-free uci_set on update option uci: maintain option position in uci_set uci: optimize update option in uci_set uci: fix use-after-free uci_add_list uci: fix atomicity of uci_add_list uci: maintain option position