ソースを参照

Strict args cheking. Fix issue #4.

git-svn-id: https://klish.googlecode.com/svn/trunk@145 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 年 前
コミット
c1edf08e96
1 ファイル変更6 行追加4 行削除
  1. 6 4
      clish/pargv/pargv.c

+ 6 - 4
clish/pargv/pargv.c

@@ -278,14 +278,16 @@ clish_pargv_parse(clish_pargv_t * this,
 	 * if we've satisfied all the parameters we can now construct
 	 * an 'args' parameter if one exists
 	 */
-	if (cmd && clish_command__get_args(cmd) &&
-			(*idx < argc) && (index >= paramc)) {
+	if (cmd && (*idx < argc) && (index >= paramc)) {
 		const char *arg = lub_argv__get_arg(argv, *idx);
 		const clish_param_t *param = clish_command__get_args(cmd);
 		char *args = NULL;
 
-		/* 
-		 * put all the argument into a single string 
+		if (!param)
+			return clish_BAD_PARAM;
+
+		/*
+		 * put all the argument into a single string
 		 */
 		while (NULL != arg) {
 			bool_t quoted = lub_argv__get_quoted(argv, *idx);