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.

46 lines
1.7 KiB

  1. From 47f2fb61a3a64667bce1a8398a8fcb1b348ff122 Mon Sep 17 00:00:00 2001
  2. From: erouault <erouault>
  3. Date: Wed, 11 Jan 2017 12:15:01 +0000
  4. Subject: [PATCH] * libtiff/tif_jpeg.c: avoid integer division by zero in
  5. JPEGSetupEncode() when horizontal or vertical sampling is set to 0. Fixes
  6. http://bugzilla.maptools.org/show_bug.cgi?id=2653
  7. ---
  8. ChangeLog | 6 ++++++
  9. libtiff/tif_jpeg.c | 7 +++++++
  10. 2 files changed, 13 insertions(+)
  11. diff --git a/ChangeLog b/ChangeLog
  12. index c82bc76..a7208f5 100644
  13. --- a/ChangeLog
  14. +++ b/ChangeLog
  15. @@ -1,5 +1,11 @@
  16. 2017-01-11 Even Rouault <even.rouault at spatialys.com>
  17. + * libtiff/tif_jpeg.c: avoid integer division by zero in
  18. + JPEGSetupEncode() when horizontal or vertical sampling is set to 0.
  19. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2653
  20. +
  21. +2017-01-11 Even Rouault <even.rouault at spatialys.com>
  22. +
  23. * tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow and
  24. cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap based overflow.
  25. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2656 and
  26. diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
  27. index 38595f9..6c17c38 100644
  28. --- a/libtiff/tif_jpeg.c
  29. +++ b/libtiff/tif_jpeg.c
  30. @@ -1626,6 +1626,13 @@ JPEGSetupEncode(TIFF* tif)
  31. case PHOTOMETRIC_YCBCR:
  32. sp->h_sampling = td->td_ycbcrsubsampling[0];
  33. sp->v_sampling = td->td_ycbcrsubsampling[1];
  34. + if( sp->h_sampling == 0 || sp->v_sampling == 0 )
  35. + {
  36. + TIFFErrorExt(tif->tif_clientdata, module,
  37. + "Invalig horizontal/vertical sampling value");
  38. + return (0);
  39. + }
  40. +
  41. /*
  42. * A ReferenceBlackWhite field *must* be present since the
  43. * default value is inappropriate for YCbCr. Fill in the