@cryptotaxi247 / kubo / commits / c775a8737

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: Mateja Milosevic <minima38123@gmail.com>

Quantomic committed Jul 9, 2017 at 21:15 UTC c775a8737e98873477406035af391dc74cedac96
1 file changed +9
commands/http/parse.go
+9
@@ -64,6 +64,11 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
64
65 args := make([]string, valCount)
66
67 + //skip further checks if we have fewer provided arguments than minimum required
68 + if valCount < numRequired {
69 + return nil, fmt.Errorf("Needed at least %v argument(s), got %v", numRequired, valCount)
70 + }
71 +
72 valIndex := 0
73 requiredFile := ""
74 for _, argDef := range cmd.Arguments {
@@ -117,6 +122,10 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
122 }
123 }
124
125 + if f.FullPath() == "" {
126 + return nil, fmt.Errorf("Corrupted data passed as file argument")
127 + }
128 +
129 // if there is a required filearg, error if no files were provided
130 if len(requiredFile) > 0 && f == nil {
131 return nil, fmt.Errorf("File argument '%s' is required", requiredFile)