Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.83k stars 321 forks source link

Unable to extract thumb from Pentax K-5 DNG file #3553

Closed Hombre57 closed 7 years ago

Hombre57 commented 7 years ago

With RT4.2.1445 on win7/64, I clicked on a folder full of Pentax K-5 dng files, already edited with a previous RT version. While trying to rebuild the cache image data, RT prints an error message for each file : Could not extract thumb from xxx where xxx is the filename. However it display a thumbnail of the embedded jpeg file but can't switch to the edited version.

Step to reproduce with gtk3-bugfix branch:

Sample DNG file: http://www.rawtherapee.com/shared/test_images/Chateau%20de%20Carcassonne.dng Chateau de Carcassonne.dng.pp3.zip

Branch: gtk3-bugfix
Version: 4.2.1445
Changeset: c6c5610333b9fbbda32fd46932fa8cdb3813532e
Compiler: gcc 6.2.0
Processor: undefined
System: Windows
Bit depth: 64 bits
Gtkmm: V3.22.0
Build type: Debug
Build flags: -mthreads -mwin32 -m64 -msse2 -mfpmath=sse -std=gnu++11 -march=native -Werror=unused-label -fopenmp -Werror=unknown-pragmas -O0 -g2 -Wall -fno-omit-frame-pointer
Link flags: -mthreads -march=native -O0 -fno-omit-frame-pointer
OpenMP support: ON
MMAP support: ON
Hombre57 commented 7 years ago

Hmmm, the thumbnail images seem to be ok, so why do I get this error message ?

heckflosse commented 7 years ago

@Hombre57 Works fine here with your file on Win7/64 master branch

Floessie commented 7 years ago

@Hombre57 I recently (#3529) put some new code in to check for bad thumbnails to prevent OOB accesses. If the check fails, you'll see that warning. Maybe the check is a bit too strict. Feel free to relax it. :smiley:

Best Flössie

heckflosse commented 7 years ago

@Hombre57 I confirm the bug in master. In the post above I was misled by the fact that the tumbnail image is ok

heckflosse commented 7 years ago

@Floessie

diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc
index 77e2609..af42ce8 100644
--- a/rtengine/rtthumbnail.cc
+++ b/rtengine/rtthumbnail.cc
@@ -55,7 +55,7 @@ namespace
                 ? raw_image.get_thumbWidth() * raw_image.get_thumbHeight() * (raw_image.get_thumbBPS() / 8) * 3
                 : raw_image.get_thumbLength();

-        return raw_image.get_thumbOffset() + length < raw_image.get_file()->size;
+        return raw_image.get_thumbOffset() + length <= raw_image.get_file()->size;
     }

 }
Floessie commented 7 years ago

@heckflosse Right! :+1: I'll commit directly on master.

Floessie commented 7 years ago

@Hombre57 Please report back and close this issue when you've tested.

@heckflosse Thanks for the fix. Better one byte too few than too much. :wink:

heckflosse commented 7 years ago

@Floessie I also tested. Works fine with the patch :+1:

Hombre57 commented 7 years ago

Yep, works fine in master here too, thanks! I guess it will be the same when merged in gtk3-bugfix. Closing.