mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Better error message if panic occurs during iptables-save output parsing
This commit is contained in:
parent
b49d429f64
commit
df23697ae7
@ -61,7 +61,11 @@ func GetChainLines(table Table, save []byte) map[Chain][]byte {
|
|||||||
} else if line[0] == ':' && len(line) > 1 {
|
} else if line[0] == ':' && len(line) > 1 {
|
||||||
// We assume that the <line> contains space - chain lines have 3 fields,
|
// We assume that the <line> contains space - chain lines have 3 fields,
|
||||||
// space delimited. If there is no space, this line will panic.
|
// space delimited. If there is no space, this line will panic.
|
||||||
chain := Chain(line[1:bytes.Index(line, spaceBytes)])
|
spaceIndex := bytes.Index(line, spaceBytes)
|
||||||
|
if spaceIndex == -1 {
|
||||||
|
panic(fmt.Sprintf("Unexpected chain line in iptables-save output: %v", string(line)))
|
||||||
|
}
|
||||||
|
chain := Chain(line[1:spaceIndex])
|
||||||
chainsMap[chain] = line
|
chainsMap[chain] = line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user