#816 Correction to r4018 to deal with segmentation fault on test file _IGP9034.JPG

v0.27.3
Robin Mills 10 years ago
parent fe0a04cd3b
commit c6ed7dfe35

@ -1152,37 +1152,39 @@ namespace Exiv2 {
const ExifData* metadata) const ExifData* metadata)
{ {
try { try {
unsigned long lensID = value.toLong(0)*256 + value.toLong(1); unsigned long lensID = value.toLong(0)*256 + value.toLong(1); // 0x3ff
unsigned long index = 0; unsigned long index = 0;
const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo")) != metadata->end()
? metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo"))
: metadata->findKey(ExifKey("Exif.Pentax.LensInfo"))
;
if ( lensInfo == metadata->end() ) return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
if ( lensInfo->count() < 5 ) return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
if ( value.count() == 2 ) { if ( value.count() == 2 ) {
// http://dev.exiv2.org/attachments/download/326/IMGP4432.PEF // http://dev.exiv2.org/attachments/download/326/IMGP4432.PEF
// exiv2 -pv --grep Lens ~/Downloads/IMGP4432.PEF // exiv2 -pv --grep Lens ~/Downloads/IMGP4432.PEF
// 0x003f Pentax LensType Byte 2 3 255 // 0x003f Pentax LensType Byte 2 3 255
// 0x0207 Pentax LensInfo Undefined 36 3 255 0 0 40 148 71 152 80 6 241 65 237 153 88 36 1 76 107 251 255 255 255 0 0 80 6 241 0 0 0 0 0 0 0 0 // 0x0207 Pentax LensInfo Undefined 36 3 255 0 0 40 148 71 152 80 6 241 65 237 153 88 36 1 76 107 251 255 255 255 0 0 80 6 241 0 0 0 0 0 0 0 0
unsigned long base = 1; unsigned long base = 1;
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Pentax.html#LensData // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Pentax.html#LensData
const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.Pentax.LensInfo")); const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.Pentax.LensInfo"));
if ( lensInfo->count() > 5 ) { unsigned int autoAperture = lensInfo->toLong(base+1) & 0x01 ;
unsigned int autoAperture = lensInfo->toLong(base+1) & 0x01 ; unsigned int minAperture = lensInfo->toLong(base+2) & 0x06 ;
unsigned int minAperture = lensInfo->toLong(base+2) & 0x06 ; unsigned int minFocusDistance = lensInfo->toLong(base+3) & 0xf8 ;
unsigned int minFocusDistance = lensInfo->toLong(base+3) & 0xf8 ; unsigned int dontKnow = lensInfo->toLong(base+4);
unsigned int dontKnow = lensInfo->toLong(base+4);
if ( autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && dontKnow == 148) index = 8; if ( autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && dontKnow == 148) index = 8;
} } else if ( value.count() == 3 ) {
} else if ( value.count() == 3 ) { // http://dev.exiv2.org/attachments/download/858/_IGP9032.DNG
// http://dev.exiv2.org/attachments/download/858/_IGP9032.DNG
// $ exiv2 -pv --grep Lens ~/Downloads/_IGP9032.DNG // $ exiv2 -pv --grep Lens ~/Downloads/_IGP9032.DNG
// 0x003f PentaxDng LensType Byte 3 3 255 0 // 0x003f PentaxDng LensType Byte 3 3 255 0
// 0x0207 PentaxDng LensInfo Undefined 69 131 0 0 255 0 40 148 68 244 ... // 0x0207 PentaxDng LensInfo Undefined 69 131 0 0 255 0 40 148 68 244 ...
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo")); if ( lensInfo->toLong(4) == 0 && lensInfo->toLong(5) == 40 && lensInfo->toLong(6) == 148 ) index = 8;
if ( lensInfo->count() > 5 ) { }
if ( lensInfo->toLong(4) == 0 && lensInfo->toLong(5) == 40 && lensInfo->toLong(6) == 148 ) index = 8;
}
}
if ( index > 0 ) { if ( index > 0 ) {
const TagDetails* td = find(pentaxLensType, lensID); const TagDetails* td = find(pentaxLensType, lensID);

@ -222,10 +222,10 @@ source ./functions.source
num=816 # test Camera: Pentax + Lens:Sigma 55-200mm F4-5.6 DC is correctly reported num=816 # test Camera: Pentax + Lens:Sigma 55-200mm F4-5.6 DC is correctly reported
printf "$num " >&3 printf "$num " >&3
echo '------>' Bug $num '<-------' >&2 echo '------>' Bug $num '<-------' >&2
for X in a b; do for X in a b c d; do
file=exiv2-bug${num}${X}.exv filename=exiv2-bug${num}${X}.exv
copyTestFile $file copyTestFile $filename
runTest exiv2 -pa --grep Lens $file runTest exiv2 -pa --grep Lens $filename
done done
num=831 num=831

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save