From e8efd7d16fb3b6e7da752657220f3ed9807d4118 Mon Sep 17 00:00:00 2001 From: flyingeagle23 Date: Mon, 11 Sep 2017 16:02:40 +0800 Subject: nat lb mapping command existed array out of bounds(VPP-979) Change-Id: Id1dce0c2eebd4097bc17842f050453b76a94eb70 Signed-off-by: flyingeagle23 --- src/plugins/nat/nat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index 8aecac6d3ff..b13c8571020 100644 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -726,7 +726,8 @@ int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, kv.key = m_key.as_u64; kv.value = m - sm->static_mappings; clib_bihash_add_del_8_8(&sm->static_mapping_by_local, &kv, 1); - locals[i].prefix = locals[i - 1].prefix + locals[i].probability; + locals[i].prefix = (i == 0) ? locals[i].probability :\ + (locals[i - 1].prefix + locals[i].probability); vec_add1 (m->locals, locals[i]); m_key.port = clib_host_to_net_u16 (locals[i].port); kv.key = m_key.as_u64; -- cgit 1.2.3-korg