]> granicus.if.org Git - strace/commitdiff
net: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)
* 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.

NEWS
net.c

diff --git a/NEWS b/NEWS
index 8e4c69919c0ef4957a50fe4ae83ef3755d473f98..fb2e5e769942fcdd00a7a56ba900c328e6ce0c51 100644 (file)
--- 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 6f04b9de62548ec368c4602b394728f8ce1b469d..ea1a3eb4ae019d92ef72c473b68db8f40aec9b6c 100644 (file)
--- 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 */