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.
This commit is contained in:
Дмитрий Левин 2017-06-02 22:22:22 +00:00
parent 32cff9dc88
commit 28e478a6eb

View File

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