summaryrefslogtreecommitdiff
path: root/package/nvram/src/cli.c
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-05-02 00:45:03 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-05-02 00:45:03 +0000
commita1dcc39e137bb68497cc421235f0a9669128c015 (patch)
tree31e4e6a2e7d9902614408a10919be3eec59336c4 /package/nvram/src/cli.c
parentec79a3d91670aad6875e9216c802facc08cbdc1e (diff)
[package] nvram: fix crash when get, set or unset is invoked without argument (#7263)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21288 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/nvram/src/cli.c')
-rw-r--r--package/nvram/src/cli.c38
1 files changed, 25 insertions, 13 deletions
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") )
{