From 672d68a8765c242dd939a31b520acbe1c9c1d7c2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 18 Aug 2008 18:49:28 +0200 Subject: [PATCH] fix lookup for section commands in the cli --- cli.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cli.c b/cli.c index cd82938..b48567f 100644 --- a/cli.c +++ b/cli.c @@ -329,10 +329,12 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) struct uci_section *s = NULL; struct uci_element *e = NULL; struct uci_option *o = NULL; + char *package = NULL; char *section = NULL; char *option = NULL; char *value = NULL; int ret = UCI_OK; + char *str; if (argc != 2) return 255; @@ -345,9 +347,20 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) return 1; } + str = strdup(argv[1]); + if (!str) + return 1; + if (value && (cmd != CMD_SET) && (cmd != CMD_ADD_LIST) && (cmd != CMD_RENAME)) return 1; + if (uci_parse_tuple(ctx, str, &package, §ion, &option, NULL) != UCI_OK) { + cli_perror(); + return 1; + } + sprintf(argv[1], "%s.%s", package, section); + free(str); + if (uci_lookup_ext(ctx, &e, argv[1]) != UCI_OK) { cli_perror(); return 1; -- 2.11.0