Bug 288958 - netstat -ia missing multicast addresses on some interfaces
Summary: netstat -ia missing multicast addresses on some interfaces
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-19 13:44 UTC by Nick Reilly
Modified: 2025-10-11 15:24 UTC (History)
1 user (show)

See Also:


Attachments
Suggested patch (385 bytes, patch)
2025-08-19 15:22 UTC, Nick Reilly
no flags Details | Diff
Updated patch (893 bytes, patch)
2025-09-12 19:31 UTC, Nick Reilly
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Reilly 2025-08-19 13:44:43 UTC
"netstat -ia" is missing multicast addresses on some interfaces. These addresses are shown correctly in "ifmcstat".

The bug is in netstat/if.c function next_ifma(), it does a strcmp() on sdl->sdl_data but the interface name may not be NULL terminated. This should be changed to a strncmp() with length sdl->sdl_nlen
Comment 1 Nick Reilly 2025-08-19 15:22:02 UTC
Created attachment 263078 [details]
Suggested patch
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2025-09-12 16:48:18 UTC
Do we also need to check that the length of "name" is equal to sdl_nlen?

Could you please attach patches emitted by git-format-patch?  That'd make it easier to apply them to the tree.
Comment 3 Nick Reilly 2025-09-12 19:31:52 UTC
Created attachment 263751 [details]
Updated patch

Added an updated patch, checking the length and from git-format-patch
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-10-03 14:32:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0952943a680dca12fe8f65f8813a9dca0783ce88

commit 0952943a680dca12fe8f65f8813a9dca0783ce88
Author:     Nick Reilly <nreilly@qnx.com>
AuthorDate: 2025-09-12 19:27:59 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-03 14:32:09 +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

 usr.bin/netstat/if.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-10-11 15:23:07 UTC
A commit in branch stable/14 references this bug:

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(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-10-11 15:23:08 UTC
A commit in branch stable/15 references this bug:

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(-)
Comment 7 Mark Johnston freebsd_committer freebsd_triage 2025-10-11 15:24:03 UTC
Thank you for the patch.