From c119a6da7c375773ff434fa1a6c8f7c070f40c43 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Fri, 6 Jan 2017 09:57:42 +0100 Subject: [PATCH] getrandom: print string as hex-escaped 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 --- getrandom.c | 3 ++- tests/getrandom.test | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/getrandom.c b/getrandom.c index 0a353adb..ea9ad572 100644 --- a/getrandom.c +++ b/getrandom.c @@ -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_???"); } diff --git a/tests/getrandom.test b/tests/getrandom.test index e06367c9..ad34048f 100755 --- a/tests/getrandom.test +++ b/tests/getrandom.test @@ -3,4 +3,4 @@ # Check getrandom syscall decoding. . "${srcdir=.}/init.sh" -run_strace_match_diff -a32 -xx -s3 +run_strace_match_diff -a32 -s3 -- 2.40.0