Skip to content

Fix reading header via chd_read_header_core_file_callbacks#146

Open
xakep666 wants to merge 1 commit intortissera:masterfrom
xakep666:fix/header_read
Open

Fix reading header via chd_read_header_core_file_callbacks#146
xakep666 wants to merge 1 commit intortissera:masterfrom
xakep666:fix/header_read

Conversation

@xakep666
Copy link
Copy Markdown

Currently this function doesn't work for CHD images version less than 4. This happens because function header_guess_unitbytes fails to properly read and populate metadata. Reason: header_guess_unitbytes uses unpopulated header from passed file pointer. A header is unpopulated because it's memory location is actually different from that one passed to header_read in a second parameter.

To fix this I've changed a signature of header_read to accept only chd_file *. And now this function will populate header data inside of this structure. It doesn't break external consumers because header_read is unexported (static). chd_read_header_core_file_callbacks a bit modified internally to copy populated header from chd_file to a user-provided pointer.

Currently this function doesn't work for CHD images version less than 4.
This happens because function `header_guess_unitbytes` fails to properly read and populate metadata.
Reason: `header_guess_unitbytes` uses _unpopulated_ header from passed file pointer.
A header is unpopulated because it's memory location is actually different from that one passed to `header_read` in a second parameter.

To fix this I've changed a signature of `header_read` to accept only `chd_file *`.
And now this function will populate header data inside of this structure.
It doesn't break external consumers because `header_read` is unexported (static).
`chd_read_header_core_file_callbacks` a bit modified internally to copy populated header from `chd_file` to a user-provided pointer.
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.

1 participant