Browse Source

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 <chenjingpiao@gmail.com>
Eugene Syromyatnikov 3 years ago
parent
commit
c119a6da7c
2 changed files with 3 additions and 2 deletions
  1. 2
    1
      getrandom.c
  2. 1
    1
      tests/getrandom.test

+ 2
- 1
getrandom.c View File

@@ -7,7 +7,8 @@ SYS_FUNC(getrandom)
7 7
 		if (syserror(tcp))
8 8
 			printaddr(tcp->u_arg[0]);
9 9
 		else
10
-			printstrn(tcp, tcp->u_arg[0], tcp->u_rval);
10
+			printstr_ex(tcp, tcp->u_arg[0], tcp->u_rval,
11
+				    QUOTE_FORCE_HEX);
11 12
 		tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
12 13
 		printflags(getrandom_flags, tcp->u_arg[2], "GRND_???");
13 14
 	}

+ 1
- 1
tests/getrandom.test View File

@@ -3,4 +3,4 @@
3 3
 # Check getrandom syscall decoding.
4 4
 
5 5
 . "${srcdir=.}/init.sh"
6
-run_strace_match_diff -a32 -xx -s3
6
+run_strace_match_diff -a32 -s3

Loading…
Cancel
Save