提交 c775a873 作者: Quantomic

Fixes #4003

Includes a general sanity check to skip further checks if user provided fewer arguments than minimum required and a specific check for corrupted data passed as file.

License: MIT
Signed-off-by: 's avatarMateja Milosevic <minima38123@gmail.com>
上级 4a779875
......@@ -64,6 +64,11 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
args := make([]string, valCount)
//skip further checks if we have fewer provided arguments than minimum required
if valCount < numRequired {
return nil, fmt.Errorf("Needed at least %v argument(s), got %v", numRequired, valCount)
}
valIndex := 0
requiredFile := ""
for _, argDef := range cmd.Arguments {
......@@ -117,6 +122,10 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
}
}
if f.FullPath() == "" {
return nil, fmt.Errorf("Corrupted data passed as file argument")
}
// if there is a required filearg, error if no files were provided
if len(requiredFile) > 0 && f == nil {
return nil, fmt.Errorf("File argument '%s' is required", requiredFile)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论