]> granicus.if.org Git - strace/commitdiff
xattr: use printstr_ex instead of print_quoted_string
authorGabriel Laskar <gabriel@lse.epita.fr>
Thu, 22 Dec 2016 15:10:51 +0000 (16:10 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 22 Dec 2016 23:11:02 +0000 (23:11 +0000)
This fixes the display when using `-s` to limit the string size
of the values displayed by {get,set}xattr.

* xattr.c (print_xattr_val): Remove static buffer.  Use printstr_ex
instead of print_quoted_string.

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

diff --git a/xattr.c b/xattr.c
index 30a8467ca390f21d130030de909e1c2b349fd9c0..721d39fc7d1abb0b6c305abcfce9269d1b379103 100644 (file)
--- 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 (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);
 }