From b8aa37676635e4c283041acdb7de61967117a60b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 2 Oct 2017 10:45:30 -0400 Subject: [PATCH] zebra: Properly initialize memory for rtadv The adata pointer was not properly being set to 0 before being used. In addition notice malloc failure and hard exit. If we have no memory on startup something terrible has gone wrong and we were going to crash shortly here anyways. Signed-off-by: Donald Sharp --- zebra/rtadv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 6091c75e50..633604120c 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -176,11 +176,13 @@ static void rtadv_send_packet(int sock, struct interface *ifp) */ if (adata == NULL) { /* XXX Free on shutdown. */ - adata = malloc(CMSG_SPACE(sizeof(struct in6_pktinfo))); + adata = calloc(1, CMSG_SPACE(sizeof(struct in6_pktinfo))); - if (adata == NULL) + if (adata == NULL) { zlog_err( "rtadv_send_packet: can't malloc control data"); + exit(-1); + } } /* Logging of packet. */ -- 2.39.5