Explorar o código

length check for parameters

Michael Yang hai 1 ano
pai
achega
40d0c4a1dc
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      parser/parser.go

+ 4 - 0
parser/parser.go

@@ -45,6 +45,10 @@ func Parse(reader io.Reader) ([]Command, error) {
 			command.Args = string(fields[1])
 		case "PARAMETER":
 			fields = bytes.SplitN(fields[1], []byte(" "), 2)
+			if len(fields) < 2 {
+				return nil, fmt.Errorf("missing value for %s", fields)
+			}
+
 			command.Name = string(fields[0])
 			command.Args = string(fields[1])
 		default: