mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
block/vhdx: Don't take address of fields in packed structs
Taking the address of a field in a packed struct is a bad idea, because it might not be actually aligned enough for that pointer type (and thus cause a crash on dereference on some host architectures). Newer versions of clang warn about this. Avoid the bug by not using the "modify in place" byte swapping functions. There are a few places where the in-place swap function is used on something other than a packed struct field; we convert those anyway, for consistency. Patch produced with scripts/coccinelle/inplace-byteswaps.cocci. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
c317b646d7
commit
1229e46d3c
4 changed files with 76 additions and 76 deletions
|
@ -835,11 +835,11 @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc,
|
|||
/* 8 + 4084 + 4 = 4096, 1 log sector */
|
||||
memcpy(&desc->leading_bytes, data, 8);
|
||||
data += 8;
|
||||
cpu_to_le64s(&desc->leading_bytes);
|
||||
desc->leading_bytes = cpu_to_le64(desc->leading_bytes);
|
||||
memcpy(sector->data, data, 4084);
|
||||
data += 4084;
|
||||
memcpy(&desc->trailing_bytes, data, 4);
|
||||
cpu_to_le32s(&desc->trailing_bytes);
|
||||
desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes);
|
||||
data += 4;
|
||||
|
||||
sector->sequence_high = (uint32_t) (seq >> 32);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue