]> granicus.if.org Git - strace/commitdiff
Fix printing of invalid l_type and l_whence in fcntl/fcntl64 syscalls
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 16 May 2016 21:57:08 +0000 (21:57 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 16 May 2016 22:41:19 +0000 (22:41 +0000)
* fcntl.c (print_struct_flock64): Explicitly cast l_type and l_whence
fields to unsigned short to avoid potential sign-extension bug when
printing invalid l_type or l_whence fields.

fcntl.c

diff --git a/fcntl.c b/fcntl.c
index 59eca9db403b33bceb045fa59d0f6d657af1e401..e446a1c6cf2d8059b72e5e7f6c94df7ec6c912d6 100644 (file)
--- a/fcntl.c
+++ b/fcntl.c
@@ -43,9 +43,9 @@ static void
 print_struct_flock64(const struct_kernel_flock64 *fl, const int getlk)
 {
        tprints("{l_type=");
-       printxval(lockfcmds, fl->l_type, "F_???");
+       printxval(lockfcmds, (unsigned short) fl->l_type, "F_???");
        tprints(", l_whence=");
-       printxval(whence_codes, fl->l_whence, "SEEK_???");
+       printxval(whence_codes, (unsigned short) fl->l_whence, "SEEK_???");
        tprintf(", l_start=%lld, l_len=%lld",
                (long long) fl->l_start, (long long) fl->l_len);
        if (getlk)