git: 146b7bb2a111 - stable/15 - netstat: Fix -ia missing multicast addresses on some interfaces

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

URL: https://cgit.FreeBSD.org/src/commit/?id=146b7bb2a111b2d01dc4ce555237a724de27f6cb

commit 146b7bb2a111b2d01dc4ce555237a724de27f6cb
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:22:45 +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 622141e4ff69..7ee03eb3689b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -282,7 +282,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;
 	}