dissect-image: reject empty partitions array

di is allocated while iterating over p.partitions. If the array is
empty,
the loop is skipped and di remains NULL, but the code still assigns
image
metadata through it.

Return EBADMSG before accessing di in this case.

Found by Linux Verification Center (linuxtesting.org) with Svace.

(cherry picked from commit d096763827)
This commit is contained in:
Mikhail Nogin
2026-05-25 17:07:57 +03:00
committed by Yu Watanabe
parent 52fbac7c56
commit 42b356b0e0

View File

@@ -5398,6 +5398,9 @@ int mountfsd_mount_image_fd(
};
}
if (!di)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Partition list is empty.");
di->single_file_system = p.single_file_system;
di->image_size = p.image_size;
di->sector_size = p.sector_size;