summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-03-31 04:57:05 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-31 05:04:42 -0700
commitc68b1e28ae9b7528aa844764e719c7267976be83 (patch)
treef95bdf6b659069b1eac659ee56e7ce5d1df6ec0c /cli/src
parent58974b02b6ebb65ee1f7baf23b0fe6c3e7fcf8cd (diff)
TOP: Validate command options
Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2628 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2628
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 69f95653d..799a64bb9 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1331,15 +1331,19 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
ret = dict_set_str (dict, "brick", value);
} else if (!strcmp (key, "list-cnt")) {
- list_cnt = atoi(value);
- if (list_cnt < 0 || list_cnt > 100) {
+ ret = gf_is_str_int (value);
+ if (!ret)
+ list_cnt = atoi (value);
+ if (ret || (list_cnt < 0) || (list_cnt > 100)) {
cli_out ("list-cnt should be between 0 to 100");
ret = -1;
goto out;
}
- } else if (perf && !strcmp (key, "bs")){
- blk_size = atoi (value);
- if (blk_size < 0){
+ } else if (perf && !strcmp (key, "bs")) {
+ ret = gf_is_str_int (value);
+ if (!ret)
+ blk_size = atoi (value);
+ if (ret || (blk_size < 0)) {
cli_out ("block size should be an integer "
"greater than zero");
ret = -1;
@@ -1347,8 +1351,10 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
}
ret = dict_set_int32 (dict, "blk-size", blk_size);
} else if (perf && !strcmp (key, "count")) {
- count = atoi(value);
- if (count < 0 ){
+ ret = gf_is_str_int (value);
+ if (!ret)
+ count = atoi(value);
+ if (ret || (count < 0)) {
cli_out ("count should be an integer greater "
"zero");
ret = -1;