Sfoglia il codice sorgente

Check and return an error when iptables version parsing fails

Federico Paolinelli 5 anni fa
parent
commit
b1deb38804
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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)