summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-10-02 16:45:30 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-10-02 17:06:06 +0200
commitb8aa37676635e4c283041acdb7de61967117a60b (patch)
tree1d1630fce9744a24e1081997e477c8f7410232cd /zebra
parentzebra: Fix valgrind report of unintialized data (diff)
downloadfrr-b8aa37676635e4c283041acdb7de61967117a60b.tar.xz
frr-b8aa37676635e4c283041acdb7de61967117a60b.zip
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 <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/rtadv.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 6091c75e5..633604120 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. */