You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.3 KiB

  1. commit 43576568ed4af4bd43409b7ff36939340141dfd6
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 11:15:18 2016 +0000
  4. * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
  5. OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
  6. Reported by Agostino Sarubbo.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
  8. diff --git a/ChangeLog b/ChangeLog
  9. index 9dbc7a0..5b23665 100644
  10. --- a/ChangeLog
  11. +++ b/ChangeLog
  12. @@ -1,5 +1,12 @@
  13. 2016-12-03 Even Rouault <even.rouault at spatialys.com>
  14. + * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
  15. + OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
  16. + Reported by Agostino Sarubbo.
  17. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
  18. +
  19. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  20. +
  21. * libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
  22. instanciate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip),
  23. instead of a logic based on the total size of data. Which is faulty is
  24. diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
  25. index 30a1812..93839d8 100644
  26. --- a/libtiff/tif_ojpeg.c
  27. +++ b/libtiff/tif_ojpeg.c
  28. @@ -1,4 +1,4 @@
  29. -/* $Id: tif_ojpeg.c,v 1.65 2016-09-04 21:32:56 erouault Exp $ */
  30. +/* $Id: tif_ojpeg.c,v 1.66 2016-12-03 11:15:18 erouault Exp $ */
  31. /* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
  32. specification is now totally obsolete and deprecated for new applications and
  33. @@ -244,6 +244,7 @@ typedef enum {
  34. typedef struct {
  35. TIFF* tif;
  36. + int decoder_ok;
  37. #ifndef LIBJPEG_ENCAP_EXTERNAL
  38. JMP_BUF exit_jmpbuf;
  39. #endif
  40. @@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
  41. }
  42. sp->write_curstrile++;
  43. }
  44. + sp->decoder_ok = 1;
  45. return(1);
  46. }
  47. @@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
  48. static int
  49. OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
  50. {
  51. + static const char module[]="OJPEGDecode";
  52. OJPEGState* sp=(OJPEGState*)tif->tif_data;
  53. (void)s;
  54. + if( !sp->decoder_ok )
  55. + {
  56. + TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
  57. + return 0;
  58. + }
  59. if (sp->libjpeg_jpeg_query_style==0)
  60. {
  61. if (OJPEGDecodeRaw(tif,buf,cc)==0)