]> granicus.if.org Git - strace/commitdiff
Do not use off_t in sendfile decoding
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 20 Mar 2013 09:48:44 +0000 (09:48 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 20 Mar 2013 14:38:20 +0000 (14:38 +0000)
sendfile parser used to decode off_t* parameter as a pointer to host
off_t type.  With this change, it is decoded as a pointer to target long
type.

* io.c (print_off_t): New function.
(sys_sendfile): Use it.
* linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding.
* linux/metag/syscallent.h: Correct sendfile syscall name.
* linux/or1k/syscallent.h: Likewise.

io.c
linux/aarch64/syscallent1.h
linux/hppa/syscallent.h
linux/metag/syscallent.h
linux/or1k/syscallent.h
linux/tile/syscallent.h
linux/x32/syscallent.h
linux/x86_64/syscallent.h

diff --git a/io.c b/io.c
index 0e9bb32de8758814ddbba55a72709d4397bfaa1b..b7bf8327a5a32bef7d27a207235919a84259797a 100644 (file)
--- a/io.c
+++ b/io.c
@@ -250,30 +250,41 @@ sys_pwritev(struct tcb *tcp)
 }
 #endif /* HAVE_SYS_UIO_H */
 
+static void
+print_off_t(struct tcb *tcp, long addr)
+{
+       unsigned long offset;
+
+       if (!addr) {
+               tprints("NULL");
+               return;
+       }
+
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+       if (current_wordsize == 4) {
+               uint32_t off;
+
+               if (umove(tcp, addr, &off) < 0)
+                       tprintf("%#lx", addr);
+               else
+                       tprintf("[%u]", off);
+       } else
+#endif
+       if (umove(tcp, addr, &offset) < 0)
+               tprintf("%#lx", addr);
+       else
+               tprintf("[%lu]", offset);
+}
+
 int
 sys_sendfile(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               off_t offset;
-
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
                printfd(tcp, tcp->u_arg[1]);
                tprints(", ");
-               if (!tcp->u_arg[2])
-                       tprints("NULL");
-//FIXME: obviously bogus.
-//Probably should use explicit long.
-//Arches with long long offset param should use
-//sys_sendfile64, not this fn.
-               else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
-                       tprintf("%#lx", tcp->u_arg[2]);
-               else
-#ifdef HAVE_LONG_LONG_OFF_T
-                       tprintf("[%llu]", offset);
-#else
-                       tprintf("[%lu]", offset);
-#endif
+               print_off_t(tcp, tcp->u_arg[2]);
                tprintf(", %lu", tcp->u_arg[3]);
        }
        return 0;
index 7b4413d69d3e0c8b5e35778b38d089bd6c3084ee..ef95e4f2ae7ed4ce2737b55cbd1bfe73ed31ab80 100644 (file)
@@ -69,7 +69,7 @@
        { 5,    TD,     sys_pwrite,                     "pwrite64"                      }, /*   68 */
        { 5,    TD,     sys_preadv,                     "preadv"                        }, /*   69 */
        { 5,    TD,     sys_pwritev,                    "pwritev"                       }, /*   70 */
-       { 4,    TD|TN,  sys_sendfile,                   "sendfile"                      }, /*   71 */
+       { 4,    TD|TN,  sys_sendfile64,                 "sendfile"                      }, /*   71 */
        { 6,    TD,     sys_pselect6,                   "pselect6"                      }, /*   72 */
        { 5,    TD,     sys_ppoll,                      "ppoll"                         }, /*   73 */
        { 4,    TD|TS,  sys_signalfd4,                  "signalfd4"                     }, /*   74 */
        { 0,    TD,     sys_inotify_init,               "inotify_init"                  }, /* 1043 */
        { 1,    TD,     sys_eventfd,                    "eventfd"                       }, /* 1044 */
        { 3,    TD|TS,  sys_signalfd,                   "signalfd"                      }, /* 1045 */
-       { 4,    TD|TN,  sys_sendfile,                   "sendfile"                      }, /* 1046 */
+       { 4,    TD|TN,  sys_sendfile64,                 "sendfile"                      }, /* 1046 */
        { 2,    TD,     sys_ftruncate,                  "ftruncate"                     }, /* 1047 */
        { 2,    TF,     sys_truncate,                   "truncate"                      }, /* 1048 */
        { 2,    TF,     sys_stat,                       "stat"                          }, /* 1049 */
index 8d2c090b5cac54c441898fbc6c89e8727ca85f68..3969450a0aa1876e5660db6070ca67eac600ee11 100644 (file)
        { 0,    0,      sys_gettid,             "gettid"                }, /* 206 */
        { 4,    TD,     sys_readahead,          "readahead"             }, /* 207 */
        { 2,    TS,     sys_kill,               "tkill"                 }, /* 208 */
-       { 4,    TD|TN,  sys_sendfile,           "sendfile64"            }, /* 209 */
+       { 4,    TD|TN,  sys_sendfile64,         "sendfile64"            }, /* 209 */
        { 6,    0,      sys_futex,              "futex"                 }, /* 210 */
        { 3,    0,      sys_sched_setaffinity,  "sched_setaffinity"     }, /* 211 */
        { 3,    0,      sys_sched_getaffinity,  "sched_getaffinity"     }, /* 212 */
index 95f41c2e2bf9c25045afd4423d7407e4620b09a6..d03a552d66156c2b5ce66ab4b475cf3da8b25bbb 100644 (file)
@@ -69,7 +69,7 @@
        { 5,    TD,     sys_pwrite,                     "pwrite64"              }, /* 68 */
        { 5,    TD,     sys_preadv,                     "preadv"                }, /* 69 */
        { 5,    TD,     sys_pwritev,                    "pwritev"               }, /* 70 */
-       { 4,    TD|TN,  sys_sendfile64,                 "sendfile64"            }, /* 71 */
+       { 4,    TD|TN,  sys_sendfile64,                 "sendfile"              }, /* 71 */
        { 6,    TD,     sys_pselect6,                   "pselect6"              }, /* 72 */
        { 5,    TD,     sys_ppoll,                      "ppoll"                 }, /* 73 */
        { 4,    TD|TS,  sys_signalfd4,                  "signalfd4"             }, /* 74 */
index 6b8a79186e59936f57f0f7a1124bafc5d68faab8..d646897a805bad0bbcafd55fd145b7bed1f19545 100644 (file)
@@ -69,7 +69,7 @@
        { 6,    TD,     sys_pwrite,                     "pwrite64"              }, /* 68 */
        { 5,    TD,     sys_preadv,                     "preadv"                }, /* 69 */
        { 5,    TD,     sys_pwritev,                    "pwritev"               }, /* 70 */
-       { 4,    TD|TN,  sys_sendfile64,                 "sendfile64"            }, /* 71 */
+       { 4,    TD|TN,  sys_sendfile64,                 "sendfile"              }, /* 71 */
        { 6,    TD,     sys_pselect6,                   "pselect6"              }, /* 72 */
        { 5,    TD,     sys_ppoll,                      "ppoll"                 }, /* 73 */
        { 4,    TD|TS,  sys_signalfd4,                  "signalfd4"             }, /* 74 */
index a8e603a9362382022c8c0a42316d94ee5484e385..eb5023b73b25cf5b7e8cd5c2b8183fee87afabc1 100644 (file)
@@ -69,7 +69,7 @@
        { 6,    TD,     sys_pwrite,                     "pwrite64"                      }, /*   68 */
        { 5,    TD,     sys_preadv,                     "preadv"                        }, /*   69 */
        { 5,    TD,     sys_pwritev,                    "pwritev"                       }, /*   70 */
-       { 4,    TD|TN,  sys_sendfile,                   "sendfile"                      }, /*   71 */
+       { 4,    TD|TN,  sys_sendfile64,                 "sendfile"                      }, /*   71 */
        { 6,    TD,     sys_pselect6,                   "pselect6"                      }, /*   72 */
        { 5,    TD,     sys_ppoll,                      "ppoll"                         }, /*   73 */
        { 4,    TD|TS,  sys_signalfd4,                  "signalfd4"                     }, /*   74 */
index 0e656a18b5503d472ccbd56a1778fc9890a106d3..4adf66b7addcadc33ac47ab9422c73d0af3e3d26 100644 (file)
@@ -38,7 +38,7 @@
        { 1,    0,      sys_alarm,              "alarm"         },  /* 37 */
        { 3,    0,      sys_setitimer,          "setitimer"     },  /* 38 */
        { 0,    0,      sys_getpid,             "getpid"        },  /* 39 */
-       { 4,    TD|TN,  sys_sendfile,           "sendfile"      },  /* 40 */
+       { 4,    TD|TN,  sys_sendfile64,         "sendfile"      },  /* 40 */
        { 3,    TN,     sys_socket,             "socket"        },  /* 41 */
        { 3,    TN,     sys_connect,            "connect"       },  /* 42 */
        { 3,    TN,     sys_accept,             "accept"        },  /* 43 */
index 56261d8fd3a3969de165fcfd64800b688fc7daad..e56bd8e105158917be7c70f05a85ab20026d5d8d 100644 (file)
@@ -38,7 +38,7 @@
        { 1,    0,      sys_alarm,              "alarm"         },  /* 37 */
        { 3,    0,      sys_setitimer,          "setitimer"     },  /* 38 */
        { 0,    0,      sys_getpid,             "getpid"        },  /* 39 */
-       { 4,    TD|TN,  sys_sendfile,           "sendfile"      },  /* 40 */
+       { 4,    TD|TN,  sys_sendfile64,         "sendfile"      },  /* 40 */
        { 3,    TN,     sys_socket,             "socket"        },  /* 41 */
        { 3,    TN,     sys_connect,            "connect"       },  /* 42 */
        { 3,    TN,     sys_accept,             "accept"        },  /* 43 */