Skip to content
This repository was archived by the owner on Dec 1, 2017. It is now read-only.

Commit 43bc256

Browse files
author
erouault
committed
* libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues. Reported by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
1 parent 9a72a69 commit 43bc256

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Diff for: ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2016-12-03 Even Rouault <even.rouault at spatialys.com>
2+
3+
* libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
4+
OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
5+
Reported by Agostino Sarubbo.
6+
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
7+
18
2016-12-03 Even Rouault <even.rouault at spatialys.com>
29

310
* libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to

Diff for: libtiff/tif_ojpeg.c

+8
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ typedef enum {
244244

245245
typedef struct {
246246
TIFF* tif;
247+
int decoder_ok;
247248
#ifndef LIBJPEG_ENCAP_EXTERNAL
248249
JMP_BUF exit_jmpbuf;
249250
#endif
@@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
722723
}
723724
sp->write_curstrile++;
724725
}
726+
sp->decoder_ok = 1;
725727
return(1);
726728
}
727729

@@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
784786
static int
785787
OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
786788
{
789+
static const char module[]="OJPEGDecode";
787790
OJPEGState* sp=(OJPEGState*)tif->tif_data;
788791
(void)s;
792+
if( !sp->decoder_ok )
793+
{
794+
TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
795+
return 0;
796+
}
789797
if (sp->libjpeg_jpeg_query_style==0)
790798
{
791799
if (OJPEGDecodeRaw(tif,buf,cc)==0)

0 commit comments

Comments
 (0)