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.

53 lines
2.2 KiB

  1. From 02669064e927074819ce1ed39aba0fccaa167717 Mon Sep 17 00:00:00 2001
  2. From: erouault <erouault>
  3. Date: Mon, 29 May 2017 10:12:54 +0000
  4. Subject: [PATCH] * libtiff/tif_color.c: TIFFYCbCrToRGBInit(): stricter
  5. clamping to avoid int32 overflow in TIFFYCbCrtoRGB(). Fixes
  6. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1844 Credit to OSS Fuzz
  7. ---
  8. ChangeLog | 7 +++++++
  9. libtiff/tif_color.c | 6 +++---
  10. 2 files changed, 10 insertions(+), 3 deletions(-)
  11. diff --git a/ChangeLog b/ChangeLog
  12. index ee8d9d08..61116596 100644
  13. --- a/ChangeLog
  14. +++ b/ChangeLog
  15. @@ -1,3 +1,10 @@
  16. +2017-05-29 Even Rouault <even.rouault at spatialys.com>
  17. +
  18. + * libtiff/tif_color.c: TIFFYCbCrToRGBInit(): stricter clamping to avoid
  19. + int32 overflow in TIFFYCbCrtoRGB().
  20. + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1844
  21. + Credit to OSS Fuzz
  22. +
  23. 2017-05-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
  24. * configure.ac: libtiff 4.0.8 released.
  25. diff --git a/libtiff/tif_color.c b/libtiff/tif_color.c
  26. index 055ed3b2..10a5e66e 100644
  27. --- a/libtiff/tif_color.c
  28. +++ b/libtiff/tif_color.c
  29. @@ -275,10 +275,10 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
  30. for (i = 0, x = -128; i < 256; i++, x++) {
  31. int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F,
  32. refBlackWhite[5] - 128.0F, 127),
  33. - -128.0F * 64, 128.0F * 64);
  34. + -128.0F * 32, 128.0F * 32);
  35. int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F,
  36. refBlackWhite[3] - 128.0F, 127),
  37. - -128.0F * 64, 128.0F * 64);
  38. + -128.0F * 32, 128.0F * 32);
  39. ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
  40. ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
  41. @@ -286,7 +286,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
  42. ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
  43. ycbcr->Y_tab[i] =
  44. (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
  45. - -128.0F * 64, 128.0F * 64);
  46. + -128.0F * 32, 128.0F * 32);
  47. }
  48. }