Skip to contentSkip to conversation

smbios: fix uuid copy

PATCH In review Marc-André Lureau 3 participants 3 messages Sep 28, 2016 – Sep 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smbios: fix uuid copy

Since 9c5ce8db, the uuid is wrongly copied, as QemuUUID 'in' argument is already a pointer.

Fixes ASAN complaining:
hw/smbios/smbios.c:489:5: runtime error: load of address 0x7fffcdb91b00 with insufficient space for an object of type '__int128 unsigned'

---
 hw/smbios/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/smbios/smbios.c +1 -1
index 9a6552a..3a96ced 100644
@@ -486,7 +486,7 @@ static void smbios_build_type_0_table(void)
  */
 static void smbios_encode_uuid(struct smbios_uuid *uuid, QemuUUID *in)
 {
-    memcpy(uuid, &in, 16);
+    memcpy(uuid, in, 16);
     if (smbios_uuid_encoded) {
         uuid->time_low = bswap32(uuid->time_low);
         uuid->time_mid = bswap16(uuid->time_mid);
Signature · 1 line
2.10.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Marc-André Lureau

Since 9c5ce8db, the uuid is wrongly copied, as QemuUUID 'in' argument is already a pointer.

Fixes ASAN complaining:
hw/smbios/smbios.c:489:5: runtime error: load of address 0x7fffcdb91b00 with insufficient space for an object of type '__int128 unsigned'

---
 hw/smbios/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/smbios/smbios.c +0 -0
index 9a6552a..3a96ced 100644

hw/smbios/smbios.c static void smbios_build_type_0_table(void) · line 492

Quoted 8 lines
hw/smbios/smbios.c +1 -1
@@ -486,7 +486,7 @@ static void smbios_build_type_0_table(void)
  */
 static void smbios_encode_uuid(struct smbios_uuid *uuid, QemuUUID *in)
 {
-    memcpy(uuid, &in, 16);
+    memcpy(uuid, in, 16);
     if (smbios_uuid_encoded) {
         uuid->time_low = bswap32(uuid->time_low);
         uuid->time_mid = bswap16(uuid->time_mid);

Also, I think the "QemuUUID.fields" structure should be decorated with QEMU_PACKED, for documentation purposes if nothing else. (Separate question / patch, of course.)

Thanks
Laszlo

#2 lore raw
Quoted 29 lines · Laszlo Ersek
Quoted 17 lines · Marc-André Lureau

Since 9c5ce8db, the uuid is wrongly copied, as QemuUUID 'in' argument is already a pointer.

Fixes ASAN complaining:
hw/smbios/smbios.c:489:5: runtime error: load of address 0x7fffcdb91b00 with insufficient space for an object of type '__int128 unsigned'

---
 hw/smbios/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/smbios/smbios.c +0 -0
index 9a6552a..3a96ced 100644

hw/smbios/smbios.c static void smbios_build_type_0_table(void) · line 492

Quoted 8 lines
hw/smbios/smbios.c +1 -1
@@ -486,7 +486,7 @@ static void smbios_build_type_0_table(void)
  */
 static void smbios_encode_uuid(struct smbios_uuid *uuid, QemuUUID *in)
 {
-    memcpy(uuid, &in, 16);
+    memcpy(uuid, in, 16);
     if (smbios_uuid_encoded) {
         uuid->time_low = bswap32(uuid->time_low);
         uuid->time_mid = bswap16(uuid->time_mid);
Quoted 6 lines

Also, I think the "QemuUUID.fields" structure should be decorated with QEMU_PACKED, for documentation purposes if nothing else. (Separate question / patch, of course.)

Thanks
Laszlo

Wrapped the long line in commit message and queued for next pull request, thanks!

Fam