]> granicus.if.org Git - strace/commitdiff
net: fix decoding of optval argument of [gs]etsockopt SOL_NETLINK
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 16 Nov 2017 00:12:46 +0000 (00:12 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 16 Nov 2017 00:12:46 +0000 (00:12 +0000)
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.

NEWS
net.c

diff --git a/NEWS b/NEWS
index 078449cae1f0c5cd0adf3b6dae838aeb8fd620c7..87b85c7da44042005fd08221b730744c84121682 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
diff --git a/net.c b/net.c
index f3c6f6b8114a91a05fe0940f3dd49d95004c0034..3e355e38864a35ca23cf78aa21897049f4d09767 100644 (file)
--- a/net.c
+++ b/net.c
@@ -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 */