]> granicus.if.org Git - strace/blobdiff - open.c
Robustify mpers.awk against invalid input
[strace] / open.c
diff --git a/open.c b/open.c
index 4a70d89c780d14b002960f853d35f8c8c2b26ea2..974f50cd5284d9ec033535d3c79c18f51c9bfda8 100644 (file)
--- a/open.c
+++ b/open.c
@@ -84,17 +84,16 @@ tprint_open_modes(int flags)
 static int
 decode_open(struct tcb *tcp, int offset)
 {
-       if (entering(tcp)) {
-               printpath(tcp, tcp->u_arg[offset]);
-               tprints(", ");
-               /* flags */
-               tprint_open_modes(tcp->u_arg[offset + 1]);
-               if (tcp->u_arg[offset + 1] & O_CREAT) {
-                       /* mode */
-                       tprintf(", %#lo", tcp->u_arg[offset + 2]);
-               }
+       printpath(tcp, tcp->u_arg[offset]);
+       tprints(", ");
+       /* flags */
+       tprint_open_modes(tcp->u_arg[offset + 1]);
+       if (tcp->u_arg[offset + 1] & O_CREAT) {
+               /* mode */
+               tprintf(", %#lo", tcp->u_arg[offset + 2]);
        }
-       return RVAL_FD;
+
+       return RVAL_DECODED | RVAL_FD;
 }
 
 SYS_FUNC(open)
@@ -104,16 +103,14 @@ SYS_FUNC(open)
 
 SYS_FUNC(openat)
 {
-       if (entering(tcp))
-               print_dirfd(tcp, tcp->u_arg[0]);
+       print_dirfd(tcp, tcp->u_arg[0]);
        return decode_open(tcp, 1);
 }
 
 SYS_FUNC(creat)
 {
-       if (entering(tcp)) {
-               printpath(tcp, tcp->u_arg[0]);
-               tprintf(", %#lo", tcp->u_arg[1]);
-       }
-       return RVAL_FD;
+       printpath(tcp, tcp->u_arg[0]);
+       tprintf(", %#lo", tcp->u_arg[1]);
+
+       return RVAL_DECODED | RVAL_FD;
 }