From 931ebbfd920728ad65fc3711833928e181a58c72 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 17 Jul 2015 01:10:45 +0000 Subject: [PATCH] seccomp.c: use printaddr and umove_or_printaddr * seccomp.c (decode_fprog, decode_seccomp_set_mode_strict): Use printaddr. (print_seccomp_filter): Use umove_or_printaddr. --- seccomp.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/seccomp.c b/seccomp.c index 09c6bbaf..4c176a78 100644 --- a/seccomp.c +++ b/seccomp.c @@ -165,7 +165,9 @@ static void decode_fprog(struct tcb *tcp, unsigned short len, unsigned long addr) { if (!len || abbrev(tcp)) { - tprintf("{len = %u, filter = %#lx}", len, addr); + tprintf("{len = %u, filter = ", len); + printaddr(addr); + tprints("}"); } else { unsigned int i = 0; @@ -191,43 +193,34 @@ decode_fprog(struct tcb *tcp, unsigned short len, unsigned long addr) void print_seccomp_filter(struct tcb *tcp, unsigned long addr) { - if (addr) { #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 - if (current_wordsize == 4) { - struct { - unsigned short len; - uint32_t filter; - } fprog; - if (umove(tcp, addr, &fprog) < 0) - tprintf("%#lx", addr); - else - decode_fprog(tcp, fprog.len, fprog.filter); - } else { + if (current_wordsize == 4) { + struct { + unsigned short len; + uint32_t filter; + } fprog; + + if (!umove_or_printaddr(tcp, addr, &fprog)) + decode_fprog(tcp, fprog.len, fprog.filter); + } else { #endif - struct { - unsigned short len; - unsigned long filter; - } fprog; - if (umove(tcp, addr, &fprog) < 0) - tprintf("%#lx", addr); - else - decode_fprog(tcp, fprog.len, fprog.filter); + struct { + unsigned short len; + unsigned long filter; + } fprog; + + if (!umove_or_printaddr(tcp, addr, &fprog)) + decode_fprog(tcp, fprog.len, fprog.filter); #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 - } -#endif - } else { - tprints("NULL"); } +#endif } static void decode_seccomp_set_mode_strict(unsigned int flags, unsigned long addr) { tprintf("%u, ", flags); - if (addr) - tprintf("%#lx", addr); - else - tprints("NULL"); + printaddr(addr); } SYS_FUNC(seccomp) -- 2.40.0