net: fix decoding of optval argument of [gs]etsockopt SOL_NETLINK

Tweak the parser to follow the kernel behaviour.

* net.c (print_getsockopt, print_setsockopt) <SOL_NETLINK>: Fetch and
print returned value as integer iff the length is >= sizeof(int),
otherwise print the address.
* NEWS: Mention this.
This commit is contained in:
Дмитрий Левин 2017-11-16 00:12:46 +00:00
parent 15f502c78a
commit 8a7030f20a
2 changed files with 16 additions and 2 deletions

4
NEWS
View File

@ -3,8 +3,8 @@ Noteworthy changes in release ?.?? (????-??-??)
* Improvements
* Implemented decoding of netlink descriptor attributes as file descriptors.
* Implemented decoding of option name argument of getsockopt and setsockopt
syscalls for SOL_NETLINK level.
* Enhanced decoding of getsockopt and setsockopt syscalls for SOL_NETLINK
level.
* Updated the list of MSG_* constants.
Noteworthy changes in release 4.20 (2017-11-13)

14
net.c
View File

@ -601,6 +601,13 @@ print_getsockopt(struct tcb *const tcp, const unsigned int level,
return;
}
break;
case SOL_NETLINK:
if (len < (int) sizeof(int))
printaddr(addr); /* unlikely */
else
printnum_int(tcp, addr, "%d");
return;
}
/* default arg printing */
@ -825,6 +832,13 @@ print_setsockopt(struct tcb *const tcp, const unsigned int level,
return;
}
break;
case SOL_NETLINK:
if (len < (int) sizeof(int))
printaddr(addr);
else
printnum_int(tcp, addr, "%d");
return;
}
/* default arg printing */