From: Donald Sharp Date: Mon, 2 Oct 2017 14:45:30 +0000 (-0400) Subject: zebra: Properly initialize memory for rtadv X-Git-Tag: frr-4.0-dev~256^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b8aa37676635e4c283041acdb7de61967117a60b;p=mirror%2Ffrr.git 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 --- 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. */