Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.
Permalink
Browse files Browse the repository at this point in the history
* libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failu…
…re 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
  • Loading branch information
erouault committed Dec 3, 2016
1 parent 9a72a69 commit 43bc256
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2016-12-03 Even Rouault <even.rouault at spatialys.com>

* 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

2016-12-03 Even Rouault <even.rouault at spatialys.com>

* libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
Expand Down
8 changes: 8 additions & 0 deletions libtiff/tif_ojpeg.c
Expand Up @@ -244,6 +244,7 @@ typedef enum {

typedef struct {
TIFF* tif;
int decoder_ok;
#ifndef LIBJPEG_ENCAP_EXTERNAL
JMP_BUF exit_jmpbuf;
#endif
Expand Down Expand Up @@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
}
sp->write_curstrile++;
}
sp->decoder_ok = 1;
return(1);
}

Expand Down Expand Up @@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
static int
OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{
static const char module[]="OJPEGDecode";
OJPEGState* sp=(OJPEGState*)tif->tif_data;
(void)s;
if( !sp->decoder_ok )
{
TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
return 0;
}
if (sp->libjpeg_jpeg_query_style==0)
{
if (OJPEGDecodeRaw(tif,buf,cc)==0)
Expand Down

0 comments on commit 43bc256

Please sign in to comment.