Explorar el Código

Check and return an error when iptables version parsing fails

Federico Paolinelli hace 5 años
padre
commit
b1deb38804
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      iptables/iptables.go

+ 6 - 0
iptables/iptables.go

@@ -101,7 +101,13 @@ func NewWithProtocol(proto Protocol) (*IPTables, error) {
 		return nil, err
 	}
 	vstring, err := getIptablesVersionString(path)
+	if err != nil {
+		return nil, fmt.Errorf("could not get iptables version: %v", err)
+	}
 	v1, v2, v3, mode, err := extractIptablesVersion(vstring)
+	if err != nil {
+		return nil, fmt.Errorf("failed to extract iptables version from [%s]: %v", vstring, err)
+	}
 
 	checkPresent, waitPresent, randomFullyPresent := getIptablesCommandSupport(v1, v2, v3)