diff options
author | Klement Sekera <ksekera@cisco.com> | 2020-06-23 13:12:33 +0000 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-06-24 07:20:50 +0000 |
commit | f3d7bd9d4d652b1c4b687267acdb9fdb908a74bd (patch) | |
tree | 3063cd4589b6671499840d3d1f1b6c4ad7adfd43 /src/plugins/nat/nat44_cli.c | |
parent | 9c8142a43c503276f97666cb8d34b39e382f82d6 (diff) |
nat: deterministic: disallow invalid config
Prevent overflow if input network prefix is too small and crash on
packet #1 due to vector not being allocated/initialized.
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I3494cc62ce889df48cc59cc9340b5dd70338c3a8
Diffstat (limited to 'src/plugins/nat/nat44_cli.c')
-rw-r--r-- | src/plugins/nat/nat44_cli.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index c73cffa85b2..7d74f36c754 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -1858,8 +1858,13 @@ snat_det_map_command_fn (vlib_main_t * vm, } } - rv = snat_det_add_map (sm, &in_addr, (u8) in_plen, &out_addr, (u8) out_plen, - is_add); + if (in_plen > 32 || out_plen > 32) + { + error = clib_error_return (0, "network prefix length must be <= 32"); + goto done; + } + + rv = snat_det_add_map (sm, &in_addr, in_plen, &out_addr, out_plen, is_add); if (rv) { |