Skip to content

Conversation

@Millefeuille42
Copy link

@Millefeuille42 Millefeuille42 commented Dec 19, 2025

vhd-util scan can crash when ran against a VHD with a corrupt footer.

Happens when the footer reports a VHD type that should have a parent (like HD_TYPE_DIFF) while having none, causing the segfault.

This fix also escalates the error in vhd_util_scan_get_volume_parent
which was not done before.

It builds fine and is being tested on the client's pool.

This is a draft PR to get reviews before sending upstream. Do not merge.

vhd-util scan can crash when ran against a VHD with a corrupt footer.

Happens when the footer reports a VHD type that should have a parent
(like HD_TYPE_DIFF) while having none, causing the segfault.

Signed-off-by: Mathieu Labourier <[email protected]>
ASSERT(dst);
ASSERT(src);

if (!*src) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ASSERT can do nothing if compiled without debug, we could SEGFAULT on this.
Shouldn't we always check that src is not NULL?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this with Ronan. This case should not happen (worse we found was that the parent string would be empty, a NULL ptr would have been caught earlier IIRC). We added the asserts just to be sure that things don't get worse during development.

Initially I wanted to put a check at the bottom instead of an ASSERT but that should not happen and would mean we do not trust the algorithm. I'm not against adding a proper check if you think this is better though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants