[PATCH] xattr: use printstr_ex instead of print_quoted_string

Gabriel Laskar gabriel at lse.epita.fr
Thu Dec 22 10:16:23 UTC 2016


This fixes the display when using `-s` to limit the string size of the
values displayed by {get,set}xattr.

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
Reported-by: Марк Коренберг <socketpair at gmail.com>

* xattr.c (print_xattr_val): use printstr_ex instead of
print_quoted_string

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
---
 xattr.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/xattr.c b/xattr.c
index 30a8467c..8e22f7eb 100644
--- a/xattr.c
+++ b/xattr.c
@@ -45,19 +45,12 @@ print_xattr_val(struct tcb *tcp,
 		unsigned long insize,
 		unsigned long size)
 {
-	static char buf[XATTR_SIZE_MAX];
-
 	tprints(", ");
 
-	if (!addr || size > sizeof(buf))
+	if (!addr || size > XATTR_SIZE_MAX)
 		printaddr(addr);
-	else if (!size || !umoven_or_printaddr(tcp, addr, size, buf)) {
-		/* Don't print terminating NUL if there is one. */
-		if (size && buf[size - 1] == '\0')
-			--size;
-
-		print_quoted_string(buf, size, 0);
-	}
+	else
+		printstr_ex(tcp, addr, size, QUOTE_OMIT_TRAILING_0);
 	tprintf(", %lu", insize);
 }
 
-- 
2.11.0





More information about the Strace-devel mailing list