Skip to content

Commit

Permalink
Set bytes to 0 before copying IPv4 addresses/masks to avoid uninitial…
Browse files Browse the repository at this point in the history
…ized bytes

Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs committed Jan 20, 2025
1 parent 4eb74f0 commit e373c89
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions orchagent/swssnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ inline static sai_ip_address_t& copy(sai_ip_address_t& dst, const IpAddress& src
switch(sip.family)
{
case AF_INET:
memset((void*)&dst.addr, 0, sizeof(dst.addr));
dst.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
dst.addr.ip4 = sip.ip_addr.ipv4_addr;
break;
Expand All @@ -41,6 +42,7 @@ inline static sai_ip_prefix_t& copy(sai_ip_prefix_t& dst, const IpPrefix& src)
switch(ia.family)
{
case AF_INET:
memset((void*)&dst, 0, sizeof(dst));
dst.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
dst.addr.ip4 = ia.ip_addr.ipv4_addr;
dst.mask.ip4 = ma.ip_addr.ipv4_addr;
Expand Down

0 comments on commit e373c89

Please sign in to comment.