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
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
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
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
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
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
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
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
)
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)
[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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
32 matches
Mail list logo