summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-17 14:04:25 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-17 14:04:25 +0900
commit564c45b90b959f6159119fd8f28fa6479f40c717 (patch)
treebcc9631dadcd27f9dea25be0be72df200a67ddc3
parentc0d521333f7be469e4b90877475e8fcb1333acef (diff)
table: fix DeletePolicyAssignment() crash with bogus input
len(cur)-len(ps) is negative if the caller tries to remove more than currently assigned policies. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--table/policy.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/table/policy.go b/table/policy.go
index 7e3a2246..d1acac4c 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -3526,7 +3526,12 @@ func (r *RoutingPolicy) DeletePolicyAssignment(id string, dir PolicyDirection, p
}
err = r.setDefaultPolicy(id, dir, ROUTE_TYPE_NONE)
} else {
- n := make([]*Policy, 0, len(cur)-len(ps))
+ l := len(cur) - len(ps)
+ if l < 0 {
+ // try to remove more than the assigned policies...
+ l = len(cur)
+ }
+ n := make([]*Policy, 0, l)
for _, y := range cur {
found := false
for _, x := range ps {