From: Dmitry V. Levin Date: Sat, 9 Jul 2016 21:52:51 +0000 (+0000) Subject: Enhance diagnostics of address truncation in sockname family syscalls X-Git-Tag: v4.13~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36df8223a1bebd83838ae5301fa429a7fbc36c0d;p=strace Enhance diagnostics of address truncation in sockname family syscalls * net.c (decode_sockname): Print both user and kernel address lengths when the returned address is truncated. * tests/sun_path.expected: Update expected output. --- diff --git a/net.c b/net.c index 86d93fc2..245cae9a 100644 --- a/net.c +++ b/net.c @@ -225,7 +225,10 @@ decode_sockname(struct tcb *tcp) tprintf(", [%d]", ulen); } else { decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen); - tprintf(", [%d]", rlen); + if (ulen < rlen) + tprintf(", [%d->%d]", ulen, rlen); + else + tprintf(", [%d]", rlen); } return RVAL_DECODED; diff --git a/tests/sun_path.expected b/tests/sun_path.expected index 44076862..30a11c03 100644 --- a/tests/sun_path.expected +++ b/tests/sun_path.expected @@ -1,3 +1,3 @@ [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +bind\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"\}, 110\) += 0 -[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +getsockname\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"\}, \[111\]\) += 0 +[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +getsockname\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"\}, \[110->111\]\) += 0 [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +connect\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"\}, 110\) += 0