dropbox / lepton

Lepton is a tool and file format for losslessly compressing JPEGs by an average of 22%.
https://blogs.dropbox.com/tech/2016/07/lepton-image-compression-saving-22-losslessly-from-images-at-15mbs/
Apache License 2.0
5.01k stars 355 forks source link

lepton crash with specific image #101

Closed spwolf closed 6 years ago

spwolf commented 6 years ago

Hello,

We have encountered an issue with lepton.exe when encoding specific jpg image. This has been reported by @StephanBusch - big thanks to Stephan and to @danielrh for lepton.

Thanks for looking into it!

Here is the image: http://nishi.dreamhosters.com/u/c24-203.jpg

Here is the error and crash we get: C:\1>lepton-slow-best-ratio.exe c24-203.jpg test.lep lepton v1.0-08c52d9280df3d409d9246df7ff166dd94628730 lepton v1.0-08c52d9280df3d409d9246df7ff166dd94628730 Assert Failed: huffr->eof && "If 0run is longer than the block must be truncated" at (C:\Users\daniel\Source\lepton\src\lepton\jpgcoder.cc:4540) Input Size 167419 != Roundtrip Size 0 a3e06756b48f3fc895b0cad80209e9c3 != 0600000005000000ffffffff00000000 UNSUPPORTED_JPEG

C:\1>lepton v1.0-08c52d9280df3d409d9246df7ff166dd94628730 filetype of file "-" is unknown bytes needed to decompress this file UNSUPPORTED_JPEG

C:\1>lepton-slow-best-ratio.exe c24-203.jpg test.lepton lepton v1.0-08c52d9280df3d409d9246df7ff166dd94628730 lepton v1.0-08c52d9280df3d409d9246df7ff166dd94628730 Assert Failed: huffr->eof && "If 0run is longer than the block must be truncated" at (C:\Users\daniel\Source\lepton\src\lepton\jpgcoder.cc:4540)

strongcourage commented 5 years ago

Hi,

Given a crafted input, the program lepton (the latest commit 24f3bbc of master) aborted due to a failed assertion as mentioned in this issue. I am not sure it is considered as bug. PoC: https://github.com/strongcourage/PoCs/blob/master/lepton_24f3bbc/PoC_af Command: lepton $PoC /tmp/out.jpg

lepton v1.0-1.2.1-182-g24f3bbc
Assert Failed: huffr->eof && "If 0run is longer than the block must be truncated" at (../src/lepton/jpgcoder.cc:4945)
ASSERTION_FAILURE
SHORT_READ

Thanks, Manh Dung

danielrh commented 5 years ago

the assertion is because the program has recognized it as a jpeg that it cannot manage. I believe it could fall back if started with the -permissive flag