summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorflyingeagle23 <wang.hui56@zte.com.cn>2017-09-11 16:02:40 +0800
committerOle Trøan <otroan@employees.org>2017-09-12 09:04:46 +0000
commite8efd7d16fb3b6e7da752657220f3ed9807d4118 (patch)
treeedf951e411e5fa52374b9a515137c6de517a7e22 /src/plugins
parentc29940c58de3e44c0c1dd5c4eda5e0268d963b14 (diff)
nat lb mapping command existed array out of bounds(VPP-979)
Change-Id: Id1dce0c2eebd4097bc17842f050453b76a94eb70 Signed-off-by: flyingeagle23 <wang.hui56@zte.com.cn>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/nat/nat.c3
1 files changed, 2 insertions, 1 deletions
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;