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 0a76a8c765c7b8327c59646284fa78c3c27e5490 Mon Sep 17 00:00:00 2001
  2. From: erouault <erouault>
  3. Date: Wed, 11 Jan 2017 16:13:50 +0000
  4. Subject: [PATCH] * libtiff/tif_jpeg.c: validate BitsPerSample in
  5. JPEGSetupEncode() to avoid undefined behaviour caused by invalid shift
  6. exponent. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2648
  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 6517640..8e202a2 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: validate BitsPerSample in JPEGSetupEncode() to avoid
  18. + undefined behaviour caused by invalid shift exponent.
  19. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2648
  20. +
  21. +2017-01-11 Even Rouault <even.rouault at spatialys.com>
  22. +
  23. * libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
  24. of double to other data types to avoid undefined behaviour if the output range
  25. isn't big enough to hold the input value.
  26. diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
  27. index 6c17c38..192989a 100644
  28. --- a/libtiff/tif_jpeg.c
  29. +++ b/libtiff/tif_jpeg.c
  30. @@ -1632,6 +1632,13 @@ JPEGSetupEncode(TIFF* tif)
  31. "Invalig horizontal/vertical sampling value");
  32. return (0);
  33. }
  34. + if( td->td_bitspersample > 16 )
  35. + {
  36. + TIFFErrorExt(tif->tif_clientdata, module,
  37. + "BitsPerSample %d not allowed for JPEG",
  38. + td->td_bitspersample);
  39. + return (0);
  40. + }
  41. /*
  42. * A ReferenceBlackWhite field *must* be present since the