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.

45 lines
1.6 KiB

  1. commit b412777317cabbf8ed89ca38fb180991cca89b8c
  2. Author: erouault <erouault>
  3. Date: Fri Dec 2 22:13:32 2016 +0000
  4. * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that
  5. can cause various issues, such as buffer overflows in the library.
  6. Reported by Agostino Sarubbo.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598
  8. diff --git a/ChangeLog b/ChangeLog
  9. index 668b66a..0f154d6 100644
  10. --- a/ChangeLog
  11. +++ b/ChangeLog
  12. @@ -1,5 +1,12 @@
  13. 2016-12-02 Even Rouault <even.rouault at spatialys.com>
  14. + * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that
  15. + can cause various issues, such as buffer overflows in the library.
  16. + Reported by Agostino Sarubbo.
  17. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598
  18. +
  19. +2016-12-02 Even Rouault <even.rouault at spatialys.com>
  20. +
  21. * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in
  22. TIFFReadEncodedStrip() that caused an integer division by zero.
  23. Reported by Agostino Sarubbo.
  24. diff --git a/tools/tiffcp.c b/tools/tiffcp.c
  25. index 338a3d1..6dfb9a9 100644
  26. --- a/tools/tiffcp.c
  27. +++ b/tools/tiffcp.c
  28. @@ -1,4 +1,4 @@
  29. -/* $Id: tiffcp.c,v 1.55 2016-10-08 15:54:57 erouault Exp $ */
  30. +/* $Id: tiffcp.c,v 1.56 2016-12-02 22:13:32 erouault Exp $ */
  31. /*
  32. * Copyright (c) 1988-1997 Sam Leffler
  33. @@ -985,7 +985,7 @@ DECLAREcpFunc(cpDecodedStrips)
  34. tstrip_t s, ns = TIFFNumberOfStrips(in);
  35. uint32 row = 0;
  36. _TIFFmemset(buf, 0, stripsize);
  37. - for (s = 0; s < ns; s++) {
  38. + for (s = 0; s < ns && row < imagelength; s++) {
  39. tsize_t cc = (row + rowsperstrip > imagelength) ?
  40. TIFFVStripSize(in, imagelength - row) : stripsize;
  41. if (TIFFReadEncodedStrip(in, s, buf, cc) < 0