]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: double-check notify data when debugging
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 11 Apr 2018 16:54:42 +0000 (12:54 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 13 Apr 2018 21:17:42 +0000 (17:17 -0400)
clang-analyze complains that data may be null, and since we didn't
explicitly check it (although we did check the overall packet length
minus the header length) it has a point.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_packet.c

index f0b30f018603e68721ebfccc0a61a08786c2f829..1a08a0512624409c48ee1cb286caf976e9446cf7 100644 (file)
@@ -697,13 +697,13 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
                bgp_notify.code = code;
                bgp_notify.subcode = sub_code;
                bgp_notify.data = NULL;
-               bgp_notify.length = length - BGP_MSG_NOTIFY_MIN_SIZE;
+               bgp_notify.length = datalen;
                bgp_notify.raw_data = data;
 
                peer->notify.code = bgp_notify.code;
                peer->notify.subcode = bgp_notify.subcode;
 
-               if (bgp_notify.length) {
+               if (bgp_notify.length && data) {
                        bgp_notify.data =
                                XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
                        for (i = 0; i < bgp_notify.length; i++)