diff options
author | 2020-05-27 01:03:46 +0200 | |
---|---|---|
committer | 2020-07-15 17:05:13 +0000 | |
commit | 49ab961abfce43e85a8c38050e28a07f01d077e0 (patch) | |
tree | 49d7773eafd19616b470a5ca449ab7d3c98821b3 /src/vnet/udp/udp_format.c | |
parent | fa729ec6cd6c7e3ec8cd7b13ede3cc6665587aed (diff) |
misc: ipfix-export unformat u16 collector_port fix
Use %U and unformat_udp_port instead of %u for unformat() call for
u16 collector_port number in set_ipfix_exporter_command_fn() to
avoid corruption of other variables which can happen if unformat()
with %u is used with a 16-bit variable. This avoids crash due to
corrupted fib_index value.
Type: fix
Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net>
Change-Id: Id54273fcc458a7f9c5aa4025aa91711f160c1c1a
(cherry picked from commit 2dca180db989ea7afacdf4e70cc85e4408557382)
Diffstat (limited to 'src/vnet/udp/udp_format.c')
-rw-r--r-- | src/vnet/udp/udp_format.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vnet/udp/udp_format.c b/src/vnet/udp/udp_format.c index 2277e18bcdb..93e7508711b 100644 --- a/src/vnet/udp/udp_format.c +++ b/src/vnet/udp/udp_format.c @@ -82,6 +82,23 @@ format_udp_header (u8 * s, va_list * args) return s; } +uword +unformat_udp_port (unformat_input_t * input, va_list * args) +{ + u16 *result = va_arg (*args, u16 *); + int port; + + /* Numeric type. */ + if (unformat (input, "0x%x", &port) || unformat (input, "%d", &port)) + { + if (port <= 0 || port >= (1 << 16)) + return 0; + *result = port; + return 1; + } + return 0; +} + /* * fd.io coding-style-patch-verification: ON * |