From f29b7cead820feac434791a196dee2263284bbfc Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 6 Dec 2024 16:42:16 +0100 Subject: [PATCH] map: map_domain_dump fails for empty tag Fix API to handle map_domain_dump for domains with an empty tag. Type: fix Change-Id: Ie065c5863538d5851cd8f8907400255f51a2e90f Signed-off-by: Ole Troan --- src/plugins/map/map_api.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c index 1dbff4ca0d1..21a3ca5f173 100644 --- a/src/plugins/map/map_api.c +++ b/src/plugins/map/map_api.c @@ -92,10 +92,9 @@ send_domain_details (u32 map_domain_index, vl_api_registration_t * rp, map_domain_t *d = pool_elt_at_index (mm->domains, map_domain_index); /* Make sure every field is initiated (or don't skip the clib_memset()) */ - map_domain_extra_t *de = - vec_elt_at_index (mm->domain_extras, map_domain_index); - int tag_len = clib_min (ARRAY_LEN (rmp->tag), vec_len (de->tag) + 1); - + map_domain_extra_t *de = 0; + if (mm->domain_extras) + de = vec_elt_at_index (mm->domain_extras, map_domain_index); REPLY_MACRO_DETAILS4(VL_API_MAP_DOMAIN_DETAILS, rp, context, ({ rmp->domain_index = htonl (map_domain_index); @@ -113,8 +112,16 @@ send_domain_details (u32 map_domain_index, vl_api_registration_t * rp, rmp->psid_length = d->psid_length; rmp->flags = d->flags; rmp->mtu = htons (d->mtu); - memcpy (rmp->tag, de->tag, tag_len - 1); - rmp->tag[tag_len - 1] = '\0'; + if (de) + { + int tag_len = clib_min (ARRAY_LEN (rmp->tag), vec_len (de->tag) + 1); + clib_memcpy (rmp->tag, de->tag, tag_len - 1); + rmp->tag[tag_len - 1] = '\0'; + } + else + { + clib_memset (rmp->tag, 0, sizeof (rmp->tag)); + } })); } -- 2.16.6