]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_file: Compute QCOW2 cluster size as ULL
authorJiri Denemark <jdenemar@redhat.com>
Mon, 25 Oct 2021 14:30:41 +0000 (16:30 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 26 Oct 2021 08:04:43 +0000 (10:04 +0200)
While the QCOW2 cluster size is represented in only 4 bits in the QCOW2
header and thus 1 << cluster_size cannot overflow int,
qcow2GetClusterSize is supposed to return unsigned long long so we can
just compute the result as ULL rather than computing it as int and
promoting to unsigned long long.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/storage_file/storage_file_probe.c

index f5bb8b7dbb650a1a057bde8848ba293514fd93cc..dc438a5e5d7211f70cb06c0272f64abefb1fd54d 100644 (file)
@@ -487,7 +487,7 @@ qcow2GetClusterSize(const char *buf,
     clusterBits = virReadBufInt32BE(buf + QCOWX_HDR_CLUSTER_BITS_OFFSET);
 
     if (clusterBits > 0)
-        return 1 << clusterBits;
+        return 1ULL << clusterBits;
 
     return 0;
 }