0010-libtiff-tif_jpeg.c-avoid-integer-division-by-zero-in.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. Fixes CVE-2017-7595
  8. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  9. ---
  10. libtiff/tif_jpeg.c | 7 +++++++
  11. 1 file changed, 13 insertions(+)
  12. diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
  13. index 38595f98..6c17c388 100644
  14. --- a/libtiff/tif_jpeg.c
  15. +++ b/libtiff/tif_jpeg.c
  16. @@ -1626,6 +1626,13 @@ JPEGSetupEncode(TIFF* tif)
  17. case PHOTOMETRIC_YCBCR:
  18. sp->h_sampling = td->td_ycbcrsubsampling[0];
  19. sp->v_sampling = td->td_ycbcrsubsampling[1];
  20. + if( sp->h_sampling == 0 || sp->v_sampling == 0 )
  21. + {
  22. + TIFFErrorExt(tif->tif_clientdata, module,
  23. + "Invalig horizontal/vertical sampling value");
  24. + return (0);
  25. + }
  26. +
  27. /*
  28. * A ReferenceBlackWhite field *must* be present since the
  29. * default value is inappropriate for YCbCr. Fill in the
  30. --
  31. 2.11.0