Explorar o código

Check and return an error when iptables version parsing fails

Federico Paolinelli %!s(int64=5) %!d(string=hai) anos
pai
achega
b1deb38804
Modificáronse 1 ficheiros con 6 adicións e 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)