Code, that parse canon original decision data version 3 (lib/Image/ExifTool/Canon.pm#l8513 in current master) has some comment, explaining it:
elsif ($version == 3) { # newer models (little endian)
# this data is structured as follows:
# 4 bytes: all 0xff
# 4 bytes: version number (=3)
# 24 bytes: sha1 A length (=20) + sha1 A
# 24 bytes: sha1 B length (=20) + sha1 B
# 4 bytes: length of remaining data (including this length word!)
# ... some more
but it is not what the code does:
for ($i=0; ; ++$i) {
$i == 3 and undef $err, last; # success!
$raf->Read($buf2, 4) == 4 or last;
$buff .= $buf2;
my $len = Get32u(\$buf2, 0);
# (the data length includes the length word itself - doh!)
$len -= 4 if $i == 2 and $len >= 4;
# make sure records are a reasonable size (<= 64kB)
$len <= 0x10000 and $raf->Read($buf2, $len) == $len or last;
$buff .= $buf2;
}
From what I see in the code - length of remaining data appear before sha1 A/B, but the comment says - after.
Should it be consistent?
I guess I got confused only by code style.
Yes, It is consistent.
Please close the ticket as invalid, and excuse me for interrupting.
Right. Glad you sorted this out. Thanks for caring enough to post in the first place.
Last edit: Phil Harvey 2016-12-04