summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-02-03 07:37:20 +0100
committerFelix Fietkau <nbd@openwrt.org>2008-02-03 07:37:20 +0100
commitcf66ea9067d3e9ffe77f42723c5b2f9d38b05ecf (patch)
treedd83dd1b8385f7cafb2bcbc980c47cacf728627a
parent65e2c3559b451315935f9483c5f4e59d63441e54 (diff)
downloaduci-cf66ea9067d3e9ffe77f42723c5b2f9d38b05ecf.tar.gz
fix a few bugs found during code reviewv0.1
-rw-r--r--history.c2
-rw-r--r--libuci.c1
-rw-r--r--list.c6
3 files changed, 5 insertions, 4 deletions
diff --git a/history.c b/history.c
index 0526361..dcf94e0 100644
--- a/history.c
+++ b/history.c
@@ -82,7 +82,7 @@ static void uci_parse_history_line(struct uci_context *ctx, struct uci_package *
goto error;
if (option && !uci_validate_name(option))
goto error;
- if ((rename || !delete) && !uci_validate_name(value))
+ if ((rename || (!option && !delete)) && !uci_validate_name(value))
goto error;
if (rename)
diff --git a/libuci.c b/libuci.c
index fd8f30c..66e6d23 100644
--- a/libuci.c
+++ b/libuci.c
@@ -71,6 +71,7 @@ void uci_free_context(struct uci_context *ctx)
free(ctx->savedir);
UCI_TRAP_SAVE(ctx, ignore);
+ ctx->internal = true;
uci_cleanup(ctx);
uci_foreach_element_safe(&ctx->root, tmp, e) {
struct uci_package *p = uci_to_package(e);
diff --git a/list.c b/list.c
index 502f51f..a0d50d1 100644
--- a/list.c
+++ b/list.c
@@ -163,7 +163,7 @@ uci_add_history(struct uci_context *ctx, struct uci_package *p, int cmd, char *s
return;
if (value)
- size += strlen(section) + 1;
+ size += strlen(value) + 1;
h = uci_alloc_element(ctx, history, option, size);
ptr = uci_dataptr(h);
@@ -446,7 +446,7 @@ int uci_set(struct uci_context *ctx, struct uci_package *p, char *section, char
goto notfound;
s = uci_to_section(e);
- if (ctx->pctx)
+ if (ctx->pctx && ctx->pctx->merge)
ctx->pctx->section = s;
if (option) {
@@ -485,7 +485,7 @@ notfound:
uci_alloc_option(s, option, value);
else {
s = uci_alloc_section(p, value, section);
- if (ctx->pctx)
+ if (ctx->pctx && ctx->pctx->merge)
ctx->pctx->section = s;
}