mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Fix dbus message reading code on big endian hosts
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@redhat.com>
This commit is contained in:
parent
095ba43903
commit
9ed3e6c117
@ -738,7 +738,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
|
||||
|
||||
switch (*t) {
|
||||
case DBUS_TYPE_BYTE:
|
||||
GET_NEXT_VAL(unsigned char, int, "%d");
|
||||
GET_NEXT_VAL(unsigned char, unsigned char, "%d");
|
||||
break;
|
||||
|
||||
case DBUS_TYPE_BOOLEAN:
|
||||
@ -746,11 +746,11 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
|
||||
break;
|
||||
|
||||
case DBUS_TYPE_INT16:
|
||||
GET_NEXT_VAL(dbus_int16_t, int, "%d");
|
||||
GET_NEXT_VAL(dbus_int16_t, short, "%d");
|
||||
break;
|
||||
|
||||
case DBUS_TYPE_UINT16:
|
||||
GET_NEXT_VAL(dbus_uint16_t, unsigned int, "%d");
|
||||
GET_NEXT_VAL(dbus_uint16_t, unsigned short, "%d");
|
||||
break;
|
||||
|
||||
case DBUS_TYPE_INT32:
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user