diff options
author | alfred <alfred@FreeBSD.org> | 2005-10-15 06:17:29 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2005-10-15 06:17:29 +0000 |
commit | 140118d69d63dcb8e7e8859c9b02312ab05578be (patch) | |
tree | d086dd0709bdc4ffa6fdd76f1dee0ff8c1290a34 /usr.bin | |
parent | 5dceb7fc4dd5ce803060249934c7a9bad19db264 (diff) | |
download | FreeBSD-src-140118d69d63dcb8e7e8859c9b02312ab05578be.zip FreeBSD-src-140118d69d63dcb8e7e8859c9b02312ab05578be.tar.gz |
The kernel accepts sockaddrs with len set to zero for sockaddr_in
types, so refactor the code here to grab them when length is zero.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/truss/syscalls.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 04886a9..52d7885 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -578,15 +578,26 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args, long retval) { if (get_struct(fd, (void *)args[sc->offset], (void *)&ss, sizeof(ss.ss_len) + sizeof(ss.ss_family)) == -1) err(1, "get_struct %p", (void *)args[sc->offset]); - /* sockaddr_un never have the length filled in! */ - if (ss.ss_family == AF_UNIX) { - if (get_struct(fd, (void *)args[sc->offset], (void *)&ss, - sizeof(*sun)) - == -1) - err(2, "get_struct %p", (void *)args[sc->offset]); - } else { - if (get_struct(fd, (void *)args[sc->offset], (void *)&ss, ss.ss_len) - == -1) + /* + * If ss_len is 0, then try to guess from the sockaddr type. + * AF_UNIX may be initialized incorrectly, so always frob + * it by using the "right" size. + */ + if (ss.ss_len == 0 || ss.ss_family == AF_UNIX) { + switch (ss.ss_family) { + case AF_INET: + ss.ss_len = sizeof(*lsin); + break; + case AF_UNIX: + ss.ss_len = sizeof(*sun); + break; + default: + /* hurrrr */ + break; + } + } + if (get_struct(fd, (void *)args[sc->offset], (void *)&ss, ss.ss_len) + == -1) { err(2, "get_struct %p", (void *)args[sc->offset]); } |