aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat.c
diff options
context:
space:
mode:
authorAequitas <wang.junqi@zte.com.cn>2017-09-23 12:58:49 +0800
committerFlorin Coras <florin.coras@gmail.com>2017-09-26 05:22:28 +0000
commitfc4510bbdb85c5bd6ff4fc69996e78d568254091 (patch)
tree2f2ab2899bb9ab5136a8358fba77166d6ed36e05 /src/plugins/nat/nat.c
parentf91fe3b060d58713d24e302abaf950556c26601e (diff)
Memory overwritten when using unformat %u (VPP-987)
Change-Id: I7d8f807fb502d61688aa1dee25fa4edcbeb32f41 Signed-off-by: Aequitas <wang.junqi@zte.com.cn>
Diffstat (limited to 'src/plugins/nat/nat.c')
-rw-r--r--src/plugins/nat/nat.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index 612085fc132..944162556d3 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -3151,7 +3151,7 @@ snat_det_close_session_out_fn (vlib_main_t *vm,
snat_main_t *sm = &snat_main;
unformat_input_t _line_input, *line_input = &_line_input;
ip4_address_t out_addr, ext_addr, in_addr;
- u16 out_port, ext_port;
+ u32 out_port, ext_port;
snat_det_map_t * dm;
snat_det_session_t * ses;
snat_det_out_key_t key;
@@ -3182,10 +3182,10 @@ snat_det_close_session_out_fn (vlib_main_t *vm,
vlib_cli_output (vm, "no match");
else
{
- snat_det_reverse(dm, &ext_addr, out_port, &in_addr);
+ snat_det_reverse(dm, &ext_addr, (u16)out_port, &in_addr);
key.ext_host_addr = out_addr;
- key.ext_host_port = ntohs(ext_port);
- key.out_port = ntohs(out_port);
+ key.ext_host_port = ntohs((u16)ext_port);
+ key.out_port = ntohs((u16)out_port);
ses = snat_det_get_ses_by_out(dm, &out_addr, key.as_u64);
if (!ses)
vlib_cli_output (vm, "no match");
@@ -3222,7 +3222,7 @@ snat_det_close_session_in_fn (vlib_main_t *vm,
snat_main_t *sm = &snat_main;
unformat_input_t _line_input, *line_input = &_line_input;
ip4_address_t in_addr, ext_addr;
- u16 in_port, ext_port;
+ u32 in_port, ext_port;
snat_det_map_t * dm;
snat_det_session_t * ses;
snat_det_out_key_t key;
@@ -3254,8 +3254,8 @@ snat_det_close_session_in_fn (vlib_main_t *vm,
else
{
key.ext_host_addr = ext_addr;
- key.ext_host_port = ntohs (ext_port);
- ses = snat_det_find_ses_by_in (dm, &in_addr, ntohs(in_port), key);
+ key.ext_host_port = ntohs ((u16)ext_port);
+ ses = snat_det_find_ses_by_in (dm, &in_addr, ntohs((u16)in_port), key);
if (!ses)
vlib_cli_output (vm, "no match");
else