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.
This commit is contained in:
Дмитрий Левин 2017-07-09 18:43:34 +00:00
parent 92fa2ce23c
commit 7bcb1dcdbc
2 changed files with 9 additions and 10 deletions

3
NEWS
View File

@ -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.

16
net.c
View File

@ -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 */