diff options
author | ori <ori@cvs.openbsd.org> | 2018-10-24 05:19:04 +0000 |
---|---|---|
committer | ori <ori@cvs.openbsd.org> | 2018-10-24 05:19:04 +0000 |
commit | 2226ccdfa41b77b87a336ffea5306e124282b294 (patch) | |
tree | 5960afc028cb39b8b3cd90db459ee0f345516dec /usr.sbin | |
parent | 7dabe2b9a441f57a798fa328c180a7093ee7dc86 (diff) |
Fix qcow2 disk images for data sizes greater than 4 gigs.
We used to truncate the disk end by anding it with a 32 bit value.
The 32 bit value was not sign extended, which causes the disk size
to wrap at 4 gigabytes:
disk->end = (disk->end + disk->clustersz - 1) & ~(disk->clustersz - 1);
This change converts the clustersz to an off_t in order to remove the
class of errors by avoiding type conversions entirely.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/vmd/vioqcow2.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/vmd/vioqcow2.c b/usr.sbin/vmd/vioqcow2.c index 3a215599d49..28b087df39a 100644 --- a/usr.sbin/vmd/vioqcow2.c +++ b/usr.sbin/vmd/vioqcow2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioqcow2.c,v 1.9 2018/10/19 10:12:39 reyk Exp $ */ +/* $OpenBSD: vioqcow2.c,v 1.10 2018/10/24 05:19:03 ori Exp $ */ /* * Copyright (c) 2018 Ori Bernstein <ori@eigenstate.org> @@ -79,15 +79,15 @@ struct qcdisk { int fd; uint64_t *l1; off_t end; - uint32_t clustersz; + off_t clustersz; off_t disksz; /* In bytes */ - uint32_t cryptmethod; + uint32_t cryptmethod; uint32_t l1sz; off_t l1off; off_t refoff; - uint32_t refsz; + off_t refsz; uint32_t nsnap; off_t snapoff; @@ -207,7 +207,7 @@ qc2_open(struct qcdisk *disk, int *fds, size_t nfd) struct qcheader header; uint64_t backingoff; uint32_t backingsz; - size_t i; + off_t i; int version, fd; pthread_rwlock_init(&disk->lock, NULL); |