]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Properly initialize memory for rtadv
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 2 Oct 2017 14:45:30 +0000 (10:45 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 2 Oct 2017 15:06:06 +0000 (11:06 -0400)
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 <sharpd@cumulusnetworks.com>
zebra/rtadv.c

index 6091c75e50c5daef8662dd3f0e298b50062aa5f5..633604120c3a292cbf382495a62c580476550d47 100644 (file)
@@ -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. */