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.

64 lines
2.6 KiB

  1. commit 8c101323f5789ef6a0db952d53794e9c4ba48207
  2. Author: erouault <erouault>
  3. Date: Fri Dec 2 21:56:56 2016 +0000
  4. * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in
  5. TIFFReadEncodedStrip() that caused an integer division by zero.
  6. Reported by Agostino Sarubbo.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2596
  8. diff --git a/ChangeLog b/ChangeLog
  9. index 46a5d7c..668b66a 100644
  10. --- a/ChangeLog
  11. +++ b/ChangeLog
  12. @@ -1,3 +1,10 @@
  13. +2016-12-02 Even Rouault <even.rouault at spatialys.com>
  14. +
  15. + * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in
  16. + TIFFReadEncodedStrip() that caused an integer division by zero.
  17. + Reported by Agostino Sarubbo.
  18. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2596
  19. +
  20. 2016-11-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
  21. * libtiff 4.0.7 released.
  22. diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
  23. index 8003592..29a311d 100644
  24. --- a/libtiff/tif_read.c
  25. +++ b/libtiff/tif_read.c
  26. @@ -1,4 +1,4 @@
  27. -/* $Id: tif_read.c,v 1.49 2016-07-10 18:00:21 erouault Exp $ */
  28. +/* $Id: tif_read.c,v 1.50 2016-12-02 21:56:56 erouault Exp $ */
  29. /*
  30. * Copyright (c) 1988-1997 Sam Leffler
  31. @@ -346,7 +346,7 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
  32. rowsperstrip=td->td_rowsperstrip;
  33. if (rowsperstrip>td->td_imagelength)
  34. rowsperstrip=td->td_imagelength;
  35. - stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip);
  36. + stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
  37. stripinplane=(strip%stripsperplane);
  38. plane=(uint16)(strip/stripsperplane);
  39. rows=td->td_imagelength-stripinplane*rowsperstrip;
  40. diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
  41. index 8bcd0c1..5294ee7 100644
  42. --- a/libtiff/tiffiop.h
  43. +++ b/libtiff/tiffiop.h
  44. @@ -1,4 +1,4 @@
  45. -/* $Id: tiffiop.h,v 1.89 2016-01-23 21:20:34 erouault Exp $ */
  46. +/* $Id: tiffiop.h,v 1.90 2016-12-02 21:56:56 erouault Exp $ */
  47. /*
  48. * Copyright (c) 1988-1997 Sam Leffler
  49. @@ -250,6 +250,10 @@ struct tiff {
  50. #define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \
  51. ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
  52. 0U)
  53. +/* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
  54. +/* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
  55. +#define TIFFhowmany_32_maxuint_compat(x, y) \
  56. + (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0))
  57. #define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
  58. #define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y))
  59. #define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y)))