]> granicus.if.org Git - strace/commitdiff
When accessing data blocks, truncate addr to wordsize
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 24 Feb 2012 23:43:22 +0000 (00:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 24 Feb 2012 23:43:22 +0000 (00:43 +0100)
* util.c (umoven): Truncate addr to wordsize before use.

util.c

diff --git a/util.c b/util.c
index 3e6269fd843f24966c322bf5fca3dfe844800087..2abfce362adf615704e8966eccdb6fc91c80bbd4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -831,6 +831,11 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
                char x[sizeof(long)];
        } u;
 
+#if SUPPORTED_PERSONALITIES > 1
+       if (personality_wordsize[current_personality] < sizeof(addr))
+               addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
+#endif
+
        if (!process_vm_readv_not_supported) {
                struct iovec local[1], remote[1];
                int r;
@@ -855,11 +860,6 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
        }
  vm_readv_didnt_work:
 
-#if SUPPORTED_PERSONALITIES > 1
-       if (personality_wordsize[current_personality] < sizeof(addr))
-               addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
-#endif
-
        started = 0;
        if (addr & (sizeof(long) - 1)) {
                /* addr not a multiple of sizeof(long) */