From dbb622c06113ffe9114c1b89a3d08ab8eb5ceca7 Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Fri, 7 Jul 2017 09:10:17 +0800 Subject: [PATCH] netlink: print unrecognized nlmsgerr in hex * netlink.c (decode_nlmsgerr): Replace printstrn with printstr_ex and set QUOTE_FORCE_HEX flag. * tests/netlink_protocol.c (test_nlmsgerr): Update expected output. --- netlink.c | 2 +- tests/netlink_protocol.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/netlink.c b/netlink.c index f74c3a07..ca195359 100644 --- a/netlink.c +++ b/netlink.c @@ -286,7 +286,7 @@ decode_nlmsgerr(struct tcb *const tcp, struct nlmsgerr err; if (len < sizeof(err.error)) { - printstrn(tcp, addr, len); + printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX); return; } diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c index eadc14fa..3b4791eb 100644 --- a/tests/netlink_protocol.c +++ b/tests/netlink_protocol.c @@ -223,7 +223,8 @@ test_nlmsgerr(const int fd) rc = sendto(fd, nlh, NLMSG_HDRLEN + 2, MSG_DONTWAIT, NULL, 0); printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST" - ", seq=0, pid=0}, \"42\"}, %u, MSG_DONTWAIT, NULL, 0) = %s\n", + ", seq=0, pid=0}, \"\\x34\\x32\"}" + ", %u, MSG_DONTWAIT, NULL, 0) = %s\n", fd, NLMSG_HDRLEN + 2, NLMSG_HDRLEN + 2, sprintrc(rc)); /* error message with room for the error code only */ -- 2.40.0