]> granicus.if.org Git - strace/commitdiff
sock: fix decoding of SIOCSIFNAME
authorMike Frysinger <vapier@gentoo.org>
Tue, 21 Oct 2014 12:34:08 +0000 (08:34 -0400)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 31 Oct 2014 15:18:47 +0000 (15:18 +0000)
The decoding of SIOCSIFNAME is incorrect.  It does not use
the ifr_index field to look things up, but ifr_newname.

* sock.c (sock_ioctl): Split out SIOCSIFNAME from SIOCGIFNAME and
display ifr_newname.

sock.c

diff --git a/sock.c b/sock.c
index d04e833020e771a667135025ab51e56401729a23..7f653dcd0b7a9d1f95de35bc0f4b2b0ebe9e4faf 100644 (file)
--- a/sock.c
+++ b/sock.c
@@ -128,15 +128,23 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                if (umove(tcp, tcp->u_arg[2], &ifr) < 0)
                        tprintf(", %#lx", tcp->u_arg[2]);
                else if (syserror(tcp)) {
-                       if (code == SIOCGIFNAME || code == SIOCSIFNAME)
-                               tprintf(", {ifr_index=%d, ifr_name=???}", ifr.ifr_ifindex);
-                       else
-                               tprintf(", {ifr_name=\"%.*s\", ???}",
+                       if (code == SIOCGIFNAME) {
+                               tprintf(", {ifr_index=%d, ifr_name=???}",
+                                       ifr.ifr_ifindex);
+                       } else {
+                               tprintf(", {ifr_name=\"%.*s\", ",
                                        IFNAMSIZ, ifr.ifr_name);
-               } else if (code == SIOCGIFNAME || code == SIOCSIFNAME)
+
+                               if (code == SIOCSIFNAME)
+                                       tprintf("ifr_newname=\"%.*s\"}",
+                                               IFNAMSIZ, ifr.ifr_newname);
+                               else
+                                       tprintf("???}");
+                       }
+               } else if (code == SIOCGIFNAME) {
                        tprintf(", {ifr_index=%d, ifr_name=\"%.*s\"}",
                                ifr.ifr_ifindex, IFNAMSIZ, ifr.ifr_name);
-               else {
+               else {
                        tprintf(", {ifr_name=\"%.*s\", ",
                                IFNAMSIZ, ifr.ifr_name);
                        switch (code) {
@@ -191,6 +199,10 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                        case SIOCSIFMTU:
                                tprintf("ifr_mtu=%d", ifr.ifr_mtu);
                                break;
+                       case SIOCSIFNAME:
+                               tprintf("ifr_newname=\"%.*s\"",
+                                       IFNAMSIZ, ifr.ifr_newname);
+                               break;
                        case SIOCGIFSLAVE:
                        case SIOCSIFSLAVE:
                                tprintf("ifr_slave=\"%s\"", ifr.ifr_slave);
@@ -240,7 +252,7 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                if (i > 0)
                                        tprints(", ");
                                tprintf("{\"%.*s\", {",
-                                       IFNAMSIZ, ifra[i].ifr_name);
+                                       IFNAMSIZ, ifra[i].ifr_newname);
                                if (verbose(tcp)) {
                                        printxval(addrfams,
                                                  ifra[i].ifr_addr.sa_family,