pkg/iptables: fix out of bounds err
This fixes two bugs in the iptables package that can cause out of bounds errors. Fixes: #22 Thanks to @SerialVelocity for reporting.
This commit is contained in:
parent
3facc9f34f
commit
4febbdbfe5
@ -206,7 +206,7 @@ func resetFromIndex(i int, rules []Rule) error {
|
||||
if i >= len(rules) {
|
||||
return nil
|
||||
}
|
||||
for j := range rules[i:] {
|
||||
for j := i; j < len(rules); j++ {
|
||||
if err := rules[j].Delete(); err != nil {
|
||||
return fmt.Errorf("failed to delete rule: %v", err)
|
||||
}
|
||||
@ -222,7 +222,7 @@ func deleteFromIndex(i int, rules *[]Rule) error {
|
||||
if i >= len(*rules) {
|
||||
return nil
|
||||
}
|
||||
for j := range (*rules)[i:] {
|
||||
for j := i; j < len(*rules); j++ {
|
||||
if err := (*rules)[j].Delete(); err != nil {
|
||||
return fmt.Errorf("failed to delete rule: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user