Author: jhb
Date: Sun Mar 19 00:27:07 2017
New Revision: 315523
URL: https://svnweb.freebsd.org/changeset/base/315523

Log:
  Add a Sizet type for 'size_t' values and use it instead of Int.
  
  Various size_t arguments were previously decoded as Int values instead
  which would have truncated values above 2^31 on 64-bit systems.

Modified:
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscall.h
==============================================================================
--- head/usr.bin/truss/syscall.h        Sun Mar 19 00:22:13 2017        
(r315522)
+++ head/usr.bin/truss/syscall.h        Sun Mar 19 00:27:07 2017        
(r315523)
@@ -46,7 +46,7 @@ enum Argtype { None = 1, Hex, Octal, Int
        LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
        Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
        CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,
-       Kldunloadflags,
+       Kldunloadflags, Sizet,
 
        CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
        CloudABIFDStat, CloudABIFileStat, CloudABIFileType,

Modified: head/usr.bin/truss/syscalls.c
==============================================================================
--- head/usr.bin/truss/syscalls.c       Sun Mar 19 00:22:13 2017        
(r315522)
+++ head/usr.bin/truss/syscalls.c       Sun Mar 19 00:27:07 2017        
(r315523)
@@ -231,16 +231,16 @@ static struct syscall decoded_syscalls[]
        { .name = "mknodat", .ret_type = 1, .nargs = 4,
          .args = { { Atfd, 0 }, { Name, 1 }, { Octal, 2 }, { Int, 3 } } },
        { .name = "mmap", .ret_type = 1, .nargs = 6,
-         .args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 }, { Mmapflags, 3 },
+         .args = { { Ptr, 0 }, { Sizet, 1 }, { Mprot, 2 }, { Mmapflags, 3 },
                    { Int, 4 }, { QuadHex, 5 } } },
        { .name = "modfind", .ret_type = 1, .nargs = 1,
          .args = { { Name | IN, 0 } } },
        { .name = "mount", .ret_type = 1, .nargs = 4,
          .args = { { Name, 0 }, { Name, 1 }, { Int, 2 }, { Ptr, 3 } } },
        { .name = "mprotect", .ret_type = 1, .nargs = 3,
-         .args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 } } },
+         .args = { { Ptr, 0 }, { Sizet, 1 }, { Mprot, 2 } } },
        { .name = "munmap", .ret_type = 1, .nargs = 2,
-         .args = { { Ptr, 0 }, { Int, 1 } } },
+         .args = { { Ptr, 0 }, { Sizet, 1 } } },
        { .name = "nanosleep", .ret_type = 1, .nargs = 1,
          .args = { { Timespec, 0 } } },
        { .name = "open", .ret_type = 1, .nargs = 3,
@@ -264,14 +264,14 @@ static struct syscall decoded_syscalls[]
        { .name = "procctl", .ret_type = 1, .nargs = 4,
          .args = { { Idtype, 0 }, { Quad, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
        { .name = "read", .ret_type = 1, .nargs = 3,
-         .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 } } },
+         .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 } } },
        { .name = "readlink", .ret_type = 1, .nargs = 3,
-         .args = { { Name, 0 }, { Readlinkres | OUT, 1 }, { Int, 2 } } },
+         .args = { { Name, 0 }, { Readlinkres | OUT, 1 }, { Sizet, 2 } } },
        { .name = "readlinkat", .ret_type = 1, .nargs = 4,
          .args = { { Atfd, 0 }, { Name, 1 }, { Readlinkres | OUT, 2 },
-                   { Int, 3 } } },
+                   { Sizet, 3 } } },
        { .name = "recvfrom", .ret_type = 1, .nargs = 6,
-         .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, { Hex, 3 },
+         .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 }, { Hex, 3 
},
                    { Sockaddr | OUT, 4 }, { Ptr | OUT, 5 } } },
        { .name = "rename", .ret_type = 1, .nargs = 2,
          .args = { { Name, 0 }, { Name, 1 } } },
@@ -285,7 +285,7 @@ static struct syscall decoded_syscalls[]
          .args = { { Int, 0 }, { Fd_set, 1 }, { Fd_set, 2 }, { Fd_set, 3 },
                    { Timeval, 4 } } },
        { .name = "sendto", .ret_type = 1, .nargs = 6,
-         .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, { Hex, 3 },
+         .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 }, { Hex, 3 },
                    { Sockaddr | IN, 4 }, { Ptr | IN, 5 } } },
        { .name = "setitimer", .ret_type = 1, .nargs = 3,
          .args = { { Int, 0 }, { Itimerval, 1 }, { Itimerval | OUT, 2 } } },
@@ -355,7 +355,7 @@ static struct syscall decoded_syscalls[]
          .args = { { Idtype, 0 }, { Quad, 1 }, { ExitStatus | OUT, 2 },
                    { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
        { .name = "write", .ret_type = 1, .nargs = 3,
-         .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 } } },
+         .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 } } },
 
        /* Linux ABI */
        { .name = "linux_access", .ret_type = 1, .nargs = 2,
@@ -374,7 +374,7 @@ static struct syscall decoded_syscalls[]
        { .name = "linux_open", .ret_type = 1, .nargs = 3,
          .args = { { Name, 0 }, { Hex, 1 }, { Octal, 2 } } },
        { .name = "linux_readlink", .ret_type = 1, .nargs = 3,
-         .args = { { Name, 0 }, { Name | OUT, 1 }, { Int, 2 } } },
+         .args = { { Name, 0 }, { Name | OUT, 1 }, { Sizet, 2 } } },
        { .name = "linux_socketcall", .ret_type = 1, .nargs = 2,
          .args = { { Int, 0 }, { LinuxSockArgs, 1 } } },
        { .name = "linux_stat64", .ret_type = 1, .nargs = 2,
@@ -1167,6 +1167,9 @@ print_arg(struct syscall_args *sc, unsig
        case Long:
                fprintf(fp, "%ld", args[sc->offset]);
                break;
+       case Sizet:
+               fprintf(fp, "%zu", (size_t)args[sc->offset]);
+               break;
        case Name: {
                /* NULL-terminated string. */
                char *tmp2;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to