dissect-image: don't assert() on partition geometry from blkid

The per-partition loop in dissect_image() reads the start and size (in
512-byte sectors) of each partition from libblkid and guards the
following byte conversions with assert(). Images sizes are input,
rather than programming, so return an error instead of asserting.

Follow-up for 88b3300fdc
This commit is contained in:
Luca Boccassi
2026-07-14 16:57:14 +01:00
parent 41fc062c49
commit e6f6ced729
+6 -4
View File
@@ -1309,15 +1309,17 @@ static int dissect_image(
start = sym_blkid_partition_get_start(pp);
if (start < 0)
return errno_or_else(EIO);
assert((uint64_t) start < UINT64_MAX/512);
if ((uint64_t) start >= UINT64_MAX/512)
return log_debug_errno(SYNTHETIC_ERRNO(EOVERFLOW),
"Partition start LBA too large to convert to a byte offset, refusing.");
errno = 0;
size = sym_blkid_partition_get_size(pp);
if (size < 0)
return errno_or_else(EIO);
assert((uint64_t) size < UINT64_MAX/512);
if ((uint64_t) size >= UINT64_MAX/512)
return log_debug_errno(SYNTHETIC_ERRNO(EOVERFLOW),
"Partition size in LBA too large to convert to a byte offset, refusing.");
/* While probing we need the non-diskseq device node name to access the thing, hence mask off
* DISSECT_IMAGE_DISKSEQ_DEVNODE. */