git: 54a72bbaee2e - stable/14 - netstat: Fix -ia missing multicast addresses on some interfaces

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sat, 11 Oct 2025 15:22:37 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=54a72bbaee2eeed26f8a06bb28a1fc52f24789f7

commit 54a72bbaee2eeed26f8a06bb28a1fc52f24789f7
Author:     Nick Reilly <nreilly@qnx.com>
AuthorDate: 2025-09-12 19:27:59 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-11 15:21:48 +0000

    netstat: Fix -ia missing multicast addresses on some interfaces
    
    sdl_data isn't always NULL terminated
    
    Signed-off-by: nreilly@qnx.com
    
    PR:             288958
    Reviewed by:    markj
    MFC after:      1 week
    
    (cherry picked from commit 0952943a680dca12fe8f65f8813a9dca0783ce88)
---
 usr.bin/netstat/if.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 2ac36fde94f9..2d6e04422ed1 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -260,7 +260,8 @@ next_ifma(struct ifmaddrs *ifma, const char *name, const sa_family_t family)
 
 		sdl = (struct sockaddr_dl *)ifma->ifma_name;
 		if (ifma->ifma_addr->sa_family == family &&
-		    strcmp(sdl->sdl_data, name) == 0)
+		    sdl->sdl_nlen == strlen(name) &&
+		    strncmp(sdl->sdl_data, name, sdl->sdl_nlen) == 0)
 			break;
 	}