On Fri, Jun 02, 2017 at 06:25:28PM +0300, Dmitry V. Levin wrote:
[...]
> I suggest implementing a default decoder of NLMSG_DONE messages that
> would print the integer in case of len == sizeof(int) and fall back
> to  printstrn for other lengths.
> 
> When protocol specific netlink decoders are added, they could either
> decode NLMSG_DONE themselves (and return true) or just return false to
> fall back to default decoder.

To facilitate this approach, I'm going to apply the following change
to payload decoders:

--- a/netlink.c
+++ b/netlink.c
@@ -83,6 +83,11 @@ decode_nlmsgerr(struct tcb *const tcp,
 {
        struct nlmsgerr err;
 
+       if (len < sizeof(err.error)) {
+               printstrn(tcp, addr, len);
+               return;
+       }
+
        if (umove_or_printaddr(tcp, addr, &err.error))
                return;
 
@@ -112,11 +117,12 @@ decode_payload(struct tcb *const tcp,
               const kernel_ulong_t addr,
               const kernel_ulong_t len)
 {
-       if (nlmsghdr->nlmsg_type == NLMSG_ERROR && len >= sizeof(int)) {
+       if (nlmsghdr->nlmsg_type == NLMSG_ERROR) {
                decode_nlmsgerr(tcp, addr, len);
-       } else {
-               printstrn(tcp, addr, len);
+               return;
        }
+
+       printstrn(tcp, addr, len);
 }
 
 static void


-- 
ldv

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to