]> git.proxmox.com Git - mirror_frr.git/commitdiff
bfdd: fix coverity memory overrun
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 6 Jul 2022 10:52:17 +0000 (07:52 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 6 Jul 2022 10:52:17 +0000 (07:52 -0300)
Use the destination for the operator `sizeof()` instead of the source
which could (and is) be bigger than destination.

We are not truncating any data here it just happens that the zebra
interface data structure hardware address can be bigger due to different
types of interface.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
bfdd/bfd_packet.c

index 23778c82d50045660b4ce379451254f9af2e1530..d34d6427628e1da0a91cbbff1c660a075a176b96 100644 (file)
@@ -219,8 +219,8 @@ void ptm_bfd_echo_fp_snd(struct bfd_session *bfd)
 
        /* add eth hdr */
        eth = (struct ethhdr *)(sendbuff);
-       memcpy(eth->h_source, bfd->ifp->hw_addr, sizeof(bfd->ifp->hw_addr));
-       memcpy(eth->h_dest, bfd->peer_hw_addr, sizeof(bfd->peer_hw_addr));
+       memcpy(eth->h_source, bfd->ifp->hw_addr, sizeof(eth->h_source));
+       memcpy(eth->h_dest, bfd->peer_hw_addr, sizeof(eth->h_dest));
 
        total_len += sizeof(struct ethhdr);