From: Dmitry V. Levin Date: Fri, 2 Jun 2017 22:22:22 +0000 (+0000) Subject: netlink: move NLMSG_ERROR payload length check to nlmsgerr decoder X-Git-Tag: v4.18~140 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28e478a6ebf20a08c5af2ecd771e1a5bb4992cc0;p=strace netlink: move NLMSG_ERROR payload length check to nlmsgerr decoder Move decoder specific check to the decoder. * netlink.c (decode_payload): Move NLMSG_ERROR payload length check ... (decode_nlmsgerr): ... here. --- diff --git a/netlink.c b/netlink.c index 10ca82c0..678343c8 100644 --- 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