From: Dmitry V. Levin Date: Sun, 9 Jul 2017 18:43:34 +0000 (+0000) Subject: net: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP X-Git-Tag: v4.19~290 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bcb1dcdbc6a209cc7072975bee5c1ff27fd6393;p=strace net: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP * net.c (print_group_req): Allow option length greater than sizeof(struct group_req) to match the kernel behaviour. When the option length is invalid, print the address. * NEWS: Mention this. --- diff --git a/NEWS b/NEWS index 8e4c6991..fb2e5e76 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,8 @@ Noteworthy changes in release ?.?? (????-??-??) * Enhanced decoding of SO_PEERCRED option of getsockopt syscall. * Enhanced decoding of IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_JOIN_ANYCAST, - and IPV6_LEAVE_ANYCAST options of setsockopt syscall. + IPV6_LEAVE_ANYCAST, MCAST_JOIN_GROUP, and MCAST_LEAVE_GROUP options + of setsockopt syscall. * Implemented decoding of linux socket filter programs specified for SO_ATTACH_FILTER and SO_ATTACH_REUSEPORT_CBPF socket options. diff --git a/net.c b/net.c index 6f04b9de..ea1a3eb4 100644 --- a/net.c +++ b/net.c @@ -684,20 +684,18 @@ print_mreq6(struct tcb *const tcp, const kernel_ulong_t addr, #ifdef MCAST_JOIN_GROUP static void -print_group_req(struct tcb *const tcp, const kernel_ulong_t addr, const int len) +print_group_req(struct tcb *const tcp, const kernel_ulong_t addr, + const int len) { struct group_req greq; - if (len != sizeof(greq) || - umove(tcp, addr, &greq) < 0) { + if (len < (int) sizeof(greq)) { printaddr(addr); - return; + } else if (!umove_or_printaddr(tcp, addr, &greq)) { + PRINT_FIELD_IFINDEX("{", greq, gr_interface); + PRINT_FIELD_SOCKADDR(", ", greq, gr_group); + tprints("}"); } - - PRINT_FIELD_IFINDEX("{", greq, gr_interface); - PRINT_FIELD_SOCKADDR(", ", greq, gr_group); - tprints("}"); - } #endif /* MCAST_JOIN_GROUP */