diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-03-17 10:23:54 +0100 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2020-03-17 10:23:14 -0400 |
commit | 6e9d611a1b4f858962cccfe16625bd82aa894e25 (patch) | |
tree | f9dba65a071028a1fd82e49f30bb8d3ee149ee74 /tests | |
parent | 1a519323d3e8425f0cf58fc85a346237edf8aeac (diff) | |
download | qemu-6e9d611a1b4f858962cccfe16625bd82aa894e25.zip |
hd-geo-test: Clean up use of buf[] in create_qcow2_with_mbr()
valgrind reports write unitialized bytes from buf[]. Clear them.
ASan reports we store to misaligned address in buf[]. Use stl_le_p()
for that.
Cc: Sam Eiderman <shmuel.eiderman@oracle.com>
Cc: John Snow <jsnow@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200317092354.31831-1-armbru@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtest/hd-geo-test.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index a249800544..48e8e02d6e 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -421,7 +421,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) char *raw_path = strdup(template); char *qcow2_path = strdup(template); char cmd[100 + 2 * PATH_MAX]; - uint8_t buf[512]; + uint8_t buf[512] = {}; int i, ret, fd, offset; uint64_t qcow2_size = sectors * 512; uint8_t status, parttype, head, sector, cyl; @@ -457,8 +457,8 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) buf[offset + 0x6] = sector; buf[offset + 0x7] = cyl; - (*(uint32_t *)&buf[offset + 0x8]) = cpu_to_le32(mbr[i].start_sect); - (*(uint32_t *)&buf[offset + 0xc]) = cpu_to_le32(mbr[i].nr_sects); + stl_le_p(&buf[offset + 0x8], mbr[i].start_sect); + stl_le_p(&buf[offset + 0xc], mbr[i].nr_sects); offset += 0x10; } |