[PATCH] Fix dbus message reading code on big endian hosts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The way we were casting small (<32bit) integers was broken
on big endian hosts, causing stack smashing. This was detected
in the test suite either by test failures due to incorrect
results, or by libc/gcc abort'ing with its stack canary
triggered.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tests/virdbustest.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/virdbustest.c b/tests/virdbustest.c
index fb241ee..61de937 100644
--- a/tests/virdbustest.c
+++ b/tests/virdbustest.c
@@ -54,8 +54,8 @@ static int testMessageSimple(const void *args ATTRIBUTE_UNUSED)
     int ret = -1;
     unsigned char in_byte = 200, out_byte = 0;
     int in_bool = true, out_bool = false;
-    int in_int16 = 12000, out_int16 = 0;
-    unsigned int in_uint16 = 32000, out_uint16 = 0;
+    short in_int16 = 0xfefe, out_int16 = 0;
+    unsigned short in_uint16 = 32000, out_uint16 = 0;
     int in_int32 = 100000000, out_int32 = 0;
     unsigned int in_uint32 = 200000000, out_uint32 = 0;
     long long in_int64 = 1000000000000, out_int64 = 0;
@@ -232,8 +232,8 @@ static int testMessageStruct(const void *args ATTRIBUTE_UNUSED)
     int ret = -1;
     unsigned char in_byte = 200, out_byte = 0;
     int in_bool = true, out_bool = false;
-    int in_int16 = 12000, out_int16 = 0;
-    unsigned int in_uint16 = 32000, out_uint16 = 0;
+    short in_int16 = 12000, out_int16 = 0;
+    unsigned short in_uint16 = 32000, out_uint16 = 0;
     int in_int32 = 100000000, out_int32 = 0;
     unsigned int in_uint32 = 200000000, out_uint32 = 0;
     long long in_int64 = 1000000000000, out_int64 = 0;
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]