mirror of
https://github.com/iKarith/cppo-ng.git
synced 2025-02-07 22:30:42 +00:00
Test 2mg comment/creator blocks are "valid"
CiderPress checks that these optional areas are actually as long as the header says they are and discards them if they're not. This seems like a useful heuristic. It happens to be the only one we can perform. :)
This commit is contained in:
parent
48ee2057c5
commit
60b9d1f3c6
17
cppo
17
cppo
@ -930,15 +930,32 @@ class Disk:
|
||||
self._raw_twoimg = self.image[:hdr.hdr_len]
|
||||
if hdr.version == 1:
|
||||
if hdr.hdr_len == 64:
|
||||
# Extract comment (if it exists and is valid)
|
||||
if hdr.comment_offset and hdr.comment_len:
|
||||
self.twoimg_comment = self.image[
|
||||
hdr.comment_offset
|
||||
: hdr.comment_offset + hdr.comment_len]
|
||||
if len(self.twoimg_comment) != hdr.comment_len:
|
||||
log.warn('invalid 2mg comment: {} bytes '
|
||||
'(expected {} bytes)'.format(
|
||||
len(self.twoimg_comment),
|
||||
hdr.comment_len))
|
||||
self.twoimg_comment = None
|
||||
|
||||
# Extract creator area (if it exists and is valid)
|
||||
if hdr.creator_offset and hdr.creator_len:
|
||||
self.twoimg_creator = self.image[
|
||||
hdr.creator_offset
|
||||
: hdr.creator_offset + hdr.creator_len]
|
||||
if len(self.twoimg_creator) != hdr.creator_len:
|
||||
log.warn('invalid 2mg creator: {} bytes '
|
||||
'(expected {} bytes)'.format(
|
||||
len(self.twoimg_creator),
|
||||
hdr.creator_len))
|
||||
self.twoimg_creator = None
|
||||
|
||||
self.twoimg_locked = bool(hdr.flags & 0x80000000)
|
||||
|
||||
self.twoimg = hdr
|
||||
else:
|
||||
log.warn('2mg header length: {} (expected 64 '
|
||||
|
Loading…
x
Reference in New Issue
Block a user