]> git.proxmox.com Git - mirror_qemu.git/commit - block/dmg.c
block/dmg: extract processing of resource forks
authorPeter Wu <peter@lekensteyn.nl>
Tue, 6 Jan 2015 17:48:06 +0000 (18:48 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 6 Feb 2015 16:24:21 +0000 (17:24 +0100)
commitb0e8dc5d54225d2e7012bd306e62ac90ba6fc1ea
tree87a4cf208036a168023c00f12031be8ca78a4ca3
parent65a1c7c96a64cd69269c9ba854fa347dd0bbda0b
block/dmg: extract processing of resource forks

Besides the offset, also read the resource length. This length is now
used in the extracted function to verify the end of the resource fork
against "count" from the resource fork.

Instead of relying on the value of offset to conclude whether the
resource fork is available or not (info_begin==0), check the
rsrc_fork_length instead. This would allow a dmg file to begin with a
resource fork. This seemingly unnecessary restriction was found while
trying to craft a DMG file by hand.

Other changes:

 - Do not require resource data offset to be 0x100 (but check that it
   is within bounds though).
 - Further improve boundary checking (resource data must be within
   the resource fork).
 - Use correct value for resource data length (spotted by John Snow)
 - Consider the resource data offset when determining info_end.
   This fixes an EINVAL on the tuxpaint dmg example.

The resource fork format is documented at
https://developer.apple.com/legacy/library/documentation/mac/pdf/MoreMacintoshToolbox.pdf#page=151

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 1420566495-13284-4-git-send-email-peter@lekensteyn.nl
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/dmg.c