From b72707d560ae797627c9950038f2dba5e03b2dbe Mon Sep 17 00:00:00 2001 From: Paul Komkoff Date: Fri, 8 Oct 2021 01:24:47 +0400 Subject: [PATCH] Don't crash when adding second interface to default namespace. Namespace members used to be char[], now they are vectors. Using strlen on a default value for these vectors results in a segmentation fault. Use vec_cmp instead. While at it, fix the output format to be %v. --- lcpng_netlink.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lcpng_netlink.c b/lcpng_netlink.c index 9753015..0b46d27 100644 --- a/lcpng_netlink.c +++ b/lcpng_netlink.c @@ -407,11 +407,10 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip) nm->nl_ns.clib_file_lcp_refcnt); if ((nm->nl_ns.clib_file_lcp_refcnt > 0) && - clib_memcmp ((char *) nm->nl_ns.netns_name, (char *) lip->lip_namespace, - strlen ((char *) lip->lip_namespace))) + vec_cmp(nm->nl_ns.netns_name, lip->lip_namespace)) { - NL_WARN ("pair_add_cb: Existing netlink listener for netns %s -- this " - "itf-pair is in netns %s, will not be listened!", + NL_WARN ("pair_add_cb: Existing netlink listener for netns %v -- this " + "itf-pair is in netns %v, will not be listened!", nm->nl_ns.netns_name, lip->lip_namespace); return; }