From 1ec8848ea498015b3c28b8f070f920c623d59363 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 16 May 1998 08:31:49 +0000 Subject: Fix broken sun_len usage: it is not sun_path length but bigger --- usr.bin/netstat/unix.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c index 64bdb22..96d6fd7 100644 --- a/usr.bin/netstat/unix.c +++ b/usr.bin/netstat/unix.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)unix.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: unix.c,v 1.5 1997/08/25 16:55:00 wollman Exp $"; + "$Id: unix.c,v 1.6 1998/05/15 20:19:21 wollman Exp $"; #endif /* not lint */ /* @@ -131,6 +131,7 @@ unixdomainpr(xunp, so) struct unpcb *unp; struct sockaddr_un *sa; static int first = 1; +#define offsetof(s, e) ((char *)&((s *)0)->e - (char *)((s *)0)) unp = &xunp->xu_unp; if (unp->unp_addr) @@ -152,6 +153,8 @@ unixdomainpr(xunp, so) (long)unp->unp_vnode, (long)unp->unp_conn, (long)unp->unp_refs.lh_first, (long)unp->unp_reflink.le_next); if (sa) - printf(" %.*s", sa->sun_len, sa->sun_path); + printf(" %.*s", + sa->sun_len - offsetof(struct sockaddr_un, sun_path), + sa->sun_path); putchar('\n'); } -- cgit v1.1