From: Dmitry V. Levin Date: Thu, 16 Nov 2017 00:12:46 +0000 (+0000) Subject: net: fix decoding of optval argument of [gs]etsockopt SOL_NETLINK X-Git-Tag: v4.21~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a7030f20a79dd8368defb03fd8b74aff210ac1d;p=strace net: fix decoding of optval argument of [gs]etsockopt SOL_NETLINK Tweak the parser to follow the kernel behaviour. * net.c (print_getsockopt, print_setsockopt) : Fetch and print returned value as integer iff the length is >= sizeof(int), otherwise print the address. * NEWS: Mention this. --- diff --git a/NEWS b/NEWS index 078449ca..87b85c7d 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ Noteworthy changes in release ?.?? (????-??-??) * Improvements * Implemented decoding of netlink descriptor attributes as file descriptors. - * Implemented decoding of option name argument of getsockopt and setsockopt - syscalls for SOL_NETLINK level. + * Enhanced decoding of getsockopt and setsockopt syscalls for SOL_NETLINK + level. * Updated the list of MSG_* constants. Noteworthy changes in release 4.20 (2017-11-13) diff --git a/net.c b/net.c index f3c6f6b8..3e355e38 100644 --- a/net.c +++ b/net.c @@ -601,6 +601,13 @@ print_getsockopt(struct tcb *const tcp, const unsigned int level, return; } break; + + case SOL_NETLINK: + if (len < (int) sizeof(int)) + printaddr(addr); /* unlikely */ + else + printnum_int(tcp, addr, "%d"); + return; } /* default arg printing */ @@ -825,6 +832,13 @@ print_setsockopt(struct tcb *const tcp, const unsigned int level, return; } break; + + case SOL_NETLINK: + if (len < (int) sizeof(int)) + printaddr(addr); + else + printnum_int(tcp, addr, "%d"); + return; } /* default arg printing */