Fix reading header via chd_read_header_core_file_callbacks#146
Open
xakep666 wants to merge 1 commit intortissera:masterfrom
Open
Fix reading header via chd_read_header_core_file_callbacks#146xakep666 wants to merge 1 commit intortissera:masterfrom
chd_read_header_core_file_callbacks#146xakep666 wants to merge 1 commit intortissera:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently this function doesn't work for CHD images version less than 4. This happens because function
header_guess_unitbytesfails to properly read and populate metadata. Reason:header_guess_unitbytesuses unpopulated header from passed file pointer. A header is unpopulated because it's memory location is actually different from that one passed toheader_readin a second parameter.To fix this I've changed a signature of
header_readto accept onlychd_file *. And now this function will populate header data inside of this structure. It doesn't break external consumers becauseheader_readis unexported (static).chd_read_header_core_file_callbacksa bit modified internally to copy populated header fromchd_fileto a user-provided pointer.