From 2c01f0fa47f83ba9fc0bbb8194085fd11ec9682f Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Tue, 6 Oct 2020 00:05:28 +0300 Subject: [PATCH] zdb should not output binary data on terminal The zdb is interpreting byte array as textual string in dump_zap, but there are also binary arrays and we should not output binary data on terminal. Reviewed-by: Brian Behlendorf Reviewed-by: Igor Kozhukhov Signed-off-by: Toomas Soome External-issue: https://www.illumos.org/issues/12012 External-issue: https://www.illumos.org/issues/11713 Closes #11006 --- cmd/zdb/zdb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 24ce43505c31..dbf09a6520a1 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -1120,7 +1120,21 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size) (void) zap_lookup(os, object, attr.za_name, attr.za_integer_length, attr.za_num_integers, prop); if (attr.za_integer_length == 1) { - (void) printf("%s", (char *)prop); + if (strcmp(attr.za_name, + DSL_CRYPTO_KEY_MASTER_KEY) == 0 || + strcmp(attr.za_name, + DSL_CRYPTO_KEY_HMAC_KEY) == 0 || + strcmp(attr.za_name, DSL_CRYPTO_KEY_IV) == 0 || + strcmp(attr.za_name, DSL_CRYPTO_KEY_MAC) == 0 || + strcmp(attr.za_name, DMU_POOL_CHECKSUM_SALT) == 0) { + uint8_t *u8 = prop; + + for (i = 0; i < attr.za_num_integers; i++) { + (void) printf("%02x", u8[i]); + } + } else { + (void) printf("%s", (char *)prop); + } } else { for (i = 0; i < attr.za_num_integers; i++) { switch (attr.za_integer_length) {