From: Dmitry V. Levin Date: Tue, 14 Jul 2015 23:34:06 +0000 (+0000) Subject: print_xattr_val: do not fetch data in case of !verbose || syserror X-Git-Tag: v4.11~459 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=105c35bb199b48dc8425180dacabdf350b2d6d07;p=strace print_xattr_val: do not fetch data in case of !verbose || syserror * xattr.c (print_xattr_val): Do not fetch data in case of !verbose || syserror. Use printaddr. --- diff --git a/xattr.c b/xattr.c index da22fcee..7a14eea6 100644 --- a/xattr.c +++ b/xattr.c @@ -12,43 +12,48 @@ print_xattr_val(struct tcb *tcp, unsigned long insize, unsigned long size) { - char *buf; + char *buf = NULL; unsigned int len; + tprints(", "); + if (insize == 0) - goto failed; + goto done; len = size; if (size != (unsigned long) len) - goto failed; + goto done; if (!len) { - tprintf(", \"\", %ld", insize); + tprintf("\"\", %ld", insize); return; } + if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) + goto done; + buf = malloc(len); if (!buf) - goto failed; + goto done; - if (umoven(tcp, arg, len, buf) < 0) { + if (umoven(tcp, addr, len, buf) < 0) { free(buf); - goto failed; + buf = NULL; + goto done; } /* Don't print terminating NUL if there is one. */ if (buf[len - 1] == '\0') --len; - tprints(", "); - print_quoted_string(buf, len, 0); +done: + if (buf) { + print_quoted_string(buf, len, 0); + free(buf); + } else { + printaddr(addr); + } tprintf(", %ld", insize); - - free(buf); - return; - -failed: - tprintf(", 0x%lx, %ld", arg, insize); } SYS_FUNC(setxattr)