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.9 KiB

  1. commit 307a31765cb01245e3655ce168385dd7d51e14bd
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 15:44:15 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=2607
  8. diff --git a/ChangeLog b/ChangeLog
  9. index ac2d922..94be038 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=2607
  18. +
  19. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  20. +
  21. * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) is called,
  22. limit the return number of inks to SamplesPerPixel, so that code that parses
  23. ink names doesn't go past the end of the buffer.
  24. diff --git a/tools/tiffcp.c b/tools/tiffcp.c
  25. index c8e48c3..142cbb0 100644
  26. --- a/tools/tiffcp.c
  27. +++ b/tools/tiffcp.c
  28. @@ -1,4 +1,4 @@
  29. -/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
  30. +/* $Id: tiffcp.c,v 1.58 2016-12-03 15:44:15 erouault Exp $ */
  31. /*
  32. * Copyright (c) 1988-1997 Sam Leffler
  33. @@ -1569,7 +1569,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
  34. uint8* bufp = (uint8*) buf;
  35. uint32 tl, tw;
  36. uint32 row;
  37. - uint16 bps, bytes_per_sample;
  38. + uint16 bps = 0, bytes_per_sample;
  39. obuf = _TIFFmalloc(TIFFTileSize(out));
  40. if (obuf == NULL)
  41. @@ -1578,6 +1578,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
  42. (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
  43. (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
  44. (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
  45. + if( bps == 0 )
  46. + {
  47. + TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
  48. + _TIFFfree(obuf);
  49. + return 0;
  50. + }
  51. assert( bps % 8 == 0 );
  52. bytes_per_sample = bps/8;