]> granicus.if.org Git - strace/commitdiff
getrandom: print string as hex-escaped
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 6 Jan 2017 08:57:42 +0000 (09:57 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 6 Jan 2017 11:43:50 +0000 (11:43 +0000)
Since there is no reason to interpret the value returned by getrandom as
ASCII string, it makes sense to always print it as a hex-escaped string.

* getrandom.c (SYS_FUNC(getrandom)): Use printstr_ex instead
of printstrn, set QUOTE_FORCE_HEX in user_style parameter in order
to force hex-escaped string formatting.
* tests/getrandom.test: Remove no longer needed -xx flag as the string
is always printed in hexadecimal format now.

Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
getrandom.c
tests/getrandom.test

index 0a353adb95c42f9fa75d62820b1f72e3d5bf5afb..ea9ad5727160acd6712919c9139903512addd818 100644 (file)
@@ -7,7 +7,8 @@ SYS_FUNC(getrandom)
                if (syserror(tcp))
                        printaddr(tcp->u_arg[0]);
                else
-                       printstrn(tcp, tcp->u_arg[0], tcp->u_rval);
+                       printstr_ex(tcp, tcp->u_arg[0], tcp->u_rval,
+                                   QUOTE_FORCE_HEX);
                tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
                printflags(getrandom_flags, tcp->u_arg[2], "GRND_???");
        }
index e06367c9366b4793eb28a26b4baf8ec5f27aa4b3..ad34048fd56fb6daa109062dc49d3f594f794d4d 100755 (executable)
@@ -3,4 +3,4 @@
 # Check getrandom syscall decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a32 -xx -s3
+run_strace_match_diff -a32 -s3