commands: Ensure argument parsing maintains total argument count, so that argument validation will fail if there are too many
Matt Bell committed
Nov 4, 2014 at 18:49 UTC
37f05a8bf6759e3c5ce3be193ccbbc101d9193c7
2 files changed
+8
commands/cli/parse.go
+4
@@ -157,6 +157,10 @@ func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
157
j++
158
}
159
160
+ if len(stringArgs)-j > 0 {
161
+ args = append(args, make([]interface{}, len(stringArgs)-j))
162
+ }
163
+
164
return args, nil
165
}
166
commands/http/parse.go
+4
@@ -83,6 +83,10 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
83
}
84
}
85
86
+ if valCount-1 > 0 {
87
+ args = append(args, make([]interface{}, valCount-1))
88
+ }
89
+
90
req := cmds.NewRequest(path, opts, args, cmd)
91
92
err = cmd.CheckArguments(req)