]> granicus.if.org Git - strace/commitdiff
netlink: print unrecognized netlink messages in hex
authorJingPiao Chen <chenjingpiao@gmail.com>
Fri, 7 Jul 2017 01:44:09 +0000 (09:44 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 7 Jul 2017 16:43:41 +0000 (16:43 +0000)
* netlink.c (fetch_nlmsghdr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query): Update expected output.

netlink.c
tests/netlink_protocol.c

index cd1296fef115a85bffc00a254ca7c6646c493d2e..d09724f12eb57647bfcf0e83ce99b265c89dabac 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -53,7 +53,7 @@ fetch_nlmsghdr(struct tcb *const tcp, struct nlmsghdr *const nlmsghdr,
               const kernel_ulong_t addr, const kernel_ulong_t len)
 {
        if (len < sizeof(struct nlmsghdr)) {
-               printstrn(tcp, addr, len);
+               printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
                return false;
        }
 
index ebb93c42214d29bdc70823d771686346530c56f7..a3e09cb9a632f5b3cec69aaa098ee4f25ce7f01c 100644 (file)
@@ -83,7 +83,8 @@ send_query(const int fd)
 
        /* whole message length < sizeof(struct nlmsghdr) */
        rc = sendto(fd, req->magic, sizeof(req->magic), MSG_DONTWAIT, NULL, 0);
-       printf("sendto(%d, \"abcd\", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+       printf("sendto(%d, \"\\x61\\x62\\x63\\x64\""
+              ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
               fd, (unsigned) sizeof(req->magic), sprintrc(rc));
 
        /* a single message with some data */
@@ -155,8 +156,8 @@ send_query(const int fd)
        printf("sendto(%d, [{{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
               ", seq=0, pid=0}, \"\\x61\\x62\\x63\\x64\"}, ",
               fd, reqs->req1.nlh.nlmsg_len, NLM_F_DUMP);
-       print_quoted_memory((void *) &reqs->req2.nlh,
-                           sizeof(reqs->req2) - sizeof(req->nlh));
+       print_quoted_hex((void *) &reqs->req2.nlh,
+                        sizeof(reqs->req2) - sizeof(req->nlh));
        printf("], %u, MSG_DONTWAIT, NULL, 0) = %s\n",
               (unsigned) (sizeof(*reqs) - sizeof(req->nlh)), errstr);