]> granicus.if.org Git - strace/blobdiff - ipc_sem.c
Robustify mpers.awk against invalid input
[strace] / ipc_sem.c
index 82d47623a8e0152473121748370175e228e645da..c7351ae84cb0ef89cd90d7f9eb6204d61f9f4898 100644 (file)
--- a/ipc_sem.c
+++ b/ipc_sem.c
 #include "defs.h"
 #include "ipc_defs.h"
 
-#include <sys/sem.h>
+#ifdef HAVE_SYS_SEM_H
+# include <sys/sem.h>
+#elif defined HAVE_LINUX_SEM_H
+# include <linux/sem.h>
+#endif
 
 #include "xlat/semctl_flags.h"
 #include "xlat/semop_flags.h"
 
+#if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
 static void
 tprint_sembuf(const struct sembuf *sb)
 {
@@ -45,10 +50,12 @@ tprint_sembuf(const struct sembuf *sb)
        printflags(semop_flags, sb->sem_flg, "SEM_???");
        tprints("}");
 }
+#endif
 
 static void
 tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
 {
+#if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
        unsigned long max_count;
        struct sembuf sb;
 
@@ -78,6 +85,9 @@ tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
 
                tprints("]");
        }
+#else
+       printaddr(addr);
+#endif
        tprintf(", %lu", count);
 }
 
@@ -99,14 +109,14 @@ SYS_FUNC(semtimedop)
                tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
                tprints(", ");
 #if defined(S390) || defined(S390X)
-               printtv(tcp, tcp->u_arg[2]);
+               print_timespec(tcp, tcp->u_arg[2]);
 #else
-               printtv(tcp, tcp->u_arg[4]);
+               print_timespec(tcp, tcp->u_arg[4]);
 #endif
        } else {
                tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                tprints(", ");
-               printtv(tcp, tcp->u_arg[3]);
+               print_timespec(tcp, tcp->u_arg[3]);
        }
        return RVAL_DECODED;
 }