From 06030d8bf0921bcf333c2d3398f4a9f41ba21e2f Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 30 Jan 2024 23:13:49 +0100 Subject: [PATCH] Hostentry eattrs are now properly zeroed --- nest/rt-table.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nest/rt-table.c b/nest/rt-table.c index 80a1c225..addab2b2 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -3336,15 +3336,19 @@ rt_postconfig(struct config *c) void ea_set_hostentry(ea_list **to, rtable *dep, rtable *src, ip_addr gw, ip_addr ll, u32 lnum, u32 labels[lnum]) { - struct hostentry_adata *head = (struct hostentry_adata *) tmp_alloc_adata( - sizeof *head + sizeof(u32) * lnum - sizeof(struct adata)); + struct { + struct hostentry_adata head; + u32 label_space[lnum]; + } h; + + memset(&h, 0, sizeof h); RT_LOCKED(src, tab) - head->he = rt_get_hostentry(tab, gw, ll, dep); - memcpy(head->labels, labels, lnum * sizeof(u32)); + h.head.he = rt_get_hostentry(tab, gw, ll, dep); - ea_set_attr(to, EA_LITERAL_DIRECT_ADATA( - &ea_gen_hostentry, 0, &head->ad)); + memcpy(h.head.labels, labels, lnum * sizeof(u32)); + + ea_set_attr_data(to, &ea_gen_hostentry, 0, h.head.ad.data, (byte *) &h.head.labels[lnum] - h.head.ad.data); }