aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <otroan@employees.org>2024-12-06 16:42:16 +0100
committerDamjan Marion <dmarion@0xa5.net>2024-12-16 10:02:28 +0000
commitf29b7cead820feac434791a196dee2263284bbfc (patch)
tree407c80060bb1af6356de6d304c3c916c5f63855c /src
parentf5b832e7293c0087bc4800940cecb7efeeeb4f39 (diff)
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 <otroan@employees.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/map/map_api.c19
1 files 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));
+ }
}));
}