]> granicus.if.org Git - strace/commitdiff
x86_64: fix is_negated_errno for x32 personality
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Oct 2016 15:51:49 +0000 (15:51 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Oct 2016 15:51:49 +0000 (15:51 +0000)
* syscall.c (is_negated_errno) [X86_64]: Do not truncate kernel_ulong_t
to uint32_t for x32 personality.

syscall.c

index 90770857419c27f72d2f1898d3a612efe0bd6b85..0894733e30a46555b6d981294d7217f44b9280a6 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1174,18 +1174,18 @@ is_negated_errno(kernel_ulong_t val)
        /* Linux kernel defines MAX_ERRNO to 4095. */
        kernel_ulong_t max = -(kernel_long_t) 4095;
 
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
-       if (current_wordsize < sizeof(val)) {
+#if defined X86_64 || defined X32
+       /*
+        * current_wordsize is 4 for x32 personality
+        * but truncation _must not_ be done in it, so
+        * check current_personality instead.
+        */
+       if (current_personality == 1) {
                val = (uint32_t) val;
                max = (uint32_t) max;
        }
-#elif defined X32
-       /*
-        * current_wordsize is 4 even in personality 0 (native X32)
-        * but truncation _must not_ be done in it.
-        * can't check current_wordsize here!
-        */
-       if (current_personality != 0) {
+#elif SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+       if (current_wordsize < sizeof(val)) {
                val = (uint32_t) val;
                max = (uint32_t) max;
        }