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.

58 lines
1.8 KiB

  1. commit 6d3ef98b2415b2edfa36a5ba600d5a824c094309
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 14:42:40 2016 +0000
  4. * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
  5. missing.
  6. Reported by Agostino Sarubbo.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597
  8. diff --git a/ChangeLog b/ChangeLog
  9. index e41d00c..0d7b12d 100644
  10. --- a/ChangeLog
  11. +++ b/ChangeLog
  12. @@ -1,5 +1,12 @@
  13. 2016-12-03 Even Rouault <even.rouault at spatialys.com>
  14. + * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
  15. + missing.
  16. + Reported by Agostino Sarubbo.
  17. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597
  18. +
  19. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  20. +
  21. * tools/tiffinfo.c: fix null pointer dereference in -r mode when the image has
  22. no StripByteCount tag.
  23. Reported by Agostino Sarubbo.
  24. diff --git a/tools/tiffcp.c b/tools/tiffcp.c
  25. index 6dfb9a9..c8e48c3 100644
  26. --- a/tools/tiffcp.c
  27. +++ b/tools/tiffcp.c
  28. @@ -1,4 +1,4 @@
  29. -/* $Id: tiffcp.c,v 1.56 2016-12-02 22:13:32 erouault Exp $ */
  30. +/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
  31. /*
  32. * Copyright (c) 1988-1997 Sam Leffler
  33. @@ -1378,7 +1378,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
  34. uint8* bufp = (uint8*) buf;
  35. uint32 tw, tl;
  36. uint32 row;
  37. - uint16 bps, bytes_per_sample;
  38. + uint16 bps = 0, bytes_per_sample;
  39. tilebuf = _TIFFmalloc(tilesize);
  40. if (tilebuf == 0)
  41. @@ -1387,6 +1387,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
  42. (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
  43. (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
  44. (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
  45. + if( bps == 0 )
  46. + {
  47. + TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample");
  48. + status = 0;
  49. + goto done;
  50. + }
  51. assert( bps % 8 == 0 );
  52. bytes_per_sample = bps/8;