aboutsummaryrefslogtreecommitdiffstats
path: root/package/nvram
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-05-02 00:45:03 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-05-02 00:45:03 +0000
commit395a1f4e0c36a4c1903688a56178f2543708ea94 (patch)
tree2bb4823d6a5fddd77b31aa4cbbb2ab634ba9c5d8 /package/nvram
parent9bf8e9a230eb5473947809d80ea3c2166c1e1a86 (diff)
downloadupstream-395a1f4e0c36a4c1903688a56178f2543708ea94.tar.gz
upstream-395a1f4e0c36a4c1903688a56178f2543708ea94.tar.bz2
upstream-395a1f4e0c36a4c1903688a56178f2543708ea94.zip
nvram: fix crash when get, set or unset is invoked without argument (#7263)
SVN-Revision: 21288
Diffstat (limited to 'package/nvram')
-rw-r--r--package/nvram/Makefile2
-rw-r--r--package/nvram/src/cli.c38
2 files changed, 26 insertions, 14 deletions
diff --git a/package/nvram/Makefile b/package/nvram/Makefile
index 6ac11a9bef..f064b5fe3c 100644
--- a/package/nvram/Makefile
+++ b/package/nvram/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=nvram
-PKG_RELEASE:=5
+PKG_RELEASE:=6
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
diff --git a/package/nvram/src/cli.c b/package/nvram/src/cli.c
index 953910cd68..44d4b88fde 100644
--- a/package/nvram/src/cli.c
+++ b/package/nvram/src/cli.c
@@ -165,20 +165,32 @@ int main( int argc, const char *argv[] )
stat = do_info(nvram);
done++;
}
- else if( !strcmp(argv[i], "get") && ++i < argc )
+ else if( !strcmp(argv[i], "get") || !strcmp(argv[i], "unset") || !strcmp(argv[i], "set") )
{
- stat = do_get(nvram, argv[i]);
- done++;
- }
- else if( !strcmp(argv[i], "unset") && ++i < argc )
- {
- stat = do_unset(nvram, argv[i]);
- done++;
- }
- else if( !strcmp(argv[i], "set") && ++i < argc )
- {
- stat = do_set(nvram, argv[i]);
- done++;
+ if( (i+1) < argc )
+ {
+ switch(argv[i++][0])
+ {
+ case 'g':
+ stat = do_get(nvram, argv[i]);
+ break;
+
+ case 'u':
+ stat = do_unset(nvram, argv[i]);
+ break;
+
+ case 's':
+ stat = do_set(nvram, argv[i]);
+ break;
+ }
+ done++;
+ }
+ else
+ {
+ fprintf(stderr, "Command '%s' requires an argument!\n", argv[i]);
+ done = 0;
+ break;
+ }
}
else if( !strcmp(argv[i], "commit") )
{