]> granicus.if.org Git - strace/commitdiff
loop: fix lo_encrypt_key field output
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 1 Jan 2017 19:26:30 +0000 (22:26 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 4 Jan 2017 13:22:19 +0000 (13:22 +0000)
lo_encrypt_key is a sized string with its size specified by
lo_encrypt_key_size field, so take lo_encrypt_key_size into account.

* loop.c (decode_loop_info, decode_loop_info64): Use minimum of
LO_KEY_SIZE and lo_encrypt_key_size field value as lo_encrypt_key size.

loop.c

diff --git a/loop.c b/loop.c
index 50b9b3e4216025b14d791ad2a6dd695cdf4646a8..20e080ff4778deaabe835c064225977e0e8efef4 100644 (file)
--- a/loop.c
+++ b/loop.c
@@ -82,7 +82,8 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
        if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
                tprints(", lo_encrypt_key=");
                print_quoted_string((void *) info.lo_encrypt_key,
-                                   LO_KEY_SIZE, 0);
+                                   MIN((uint32_t) info.lo_encrypt_key_size,
+                                   LO_KEY_SIZE), 0);
        }
 
        if (!abbrev(tcp))
@@ -143,7 +144,8 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr)
                                    LO_NAME_SIZE, QUOTE_0_TERMINATED);
                tprints(", lo_encrypt_key=");
                print_quoted_string((void *) info64.lo_encrypt_key,
-                                   LO_KEY_SIZE, 0);
+                                   MIN(info64.lo_encrypt_key_size,
+                                   LO_KEY_SIZE), 0);
        }
 
        if (!abbrev(tcp))