netlink: print unrecognized nlattr in hex

* nlattr.c (fetch_nlattr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/nlattr.c (test_nlattr): Update expected output.
This commit is contained in:
JingPiao Chen 2017-07-07 09:47:17 +08:00 committed by Dmitry V. Levin
parent 5626a08061
commit d331383d7d
2 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ fetch_nlattr(struct tcb *const tcp, struct nlattr *const nlattr,
const kernel_ulong_t addr, const kernel_ulong_t len)
{
if (len < sizeof(struct nlattr)) {
printstrn(tcp, addr, len);
printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
return false;
}

View File

@ -74,7 +74,7 @@ test_nlattr(const int fd)
printf("sendto(%d, {{len=%u, type=SOCK_DIAG_BY_FAMILY"
", flags=NLM_F_DUMP, seq=0, pid=0}, {udiag_family=AF_UNIX"
", udiag_type=SOCK_STREAM, udiag_state=TCP_FIN_WAIT1"
", udiag_ino=0, udiag_cookie=[0, 0]}, \"12\"}, %u"
", udiag_ino=0, udiag_cookie=[0, 0]}, \"\\x31\\x32\"}, %u"
", MSG_DONTWAIT, NULL, 0) = %s\n",
fd, msg_len, msg_len, sprintrc(rc));
@ -154,7 +154,7 @@ test_nlattr(const int fd)
", flags=NLM_F_DUMP, seq=0, pid=0}, {udiag_family=AF_UNIX"
", udiag_type=SOCK_STREAM, udiag_state=TCP_FIN_WAIT1"
", udiag_ino=0, udiag_cookie=[0, 0]}, [{nla_len=%u"
", nla_type=UNIX_DIAG_NAME}, \"12\"]}, %u"
", nla_type=UNIX_DIAG_NAME}, \"\\x31\\x32\"]}, %u"
", MSG_DONTWAIT, NULL, 0) = %s\n",
fd, msg_len, nla->nla_len, msg_len, sprintrc(rc));