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.

70 lines
2.1 KiB

  1. commit 18bca4cf3057681689efb502175cbe5f01cb68c3
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 16:50:02 2016 +0000
  4. * tools/tiffcp.c: replace assert( (bps % 8) == 0 ) by a non assert check.
  5. Reported by Agostino Sarubbo.
  6. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2605
  7. diff --git a/ChangeLog b/ChangeLog
  8. index 8ee76c0..025eb72 100644
  9. --- a/ChangeLog
  10. +++ b/ChangeLog
  11. @@ -1,5 +1,11 @@
  12. 2016-12-03 Even Rouault <even.rouault at spatialys.com>
  13. + * tools/tiffcp.c: replace assert( (bps % 8) == 0 ) by a non assert check.
  14. + Reported by Agostino Sarubbo.
  15. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2605
  16. +
  17. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  18. +
  19. * tools/tiffcp.c: fix uint32 underflow/overflow that can cause heap-based
  20. buffer overflow.
  21. Reported by Agostino Sarubbo.
  22. diff --git a/tools/tiffcp.c b/tools/tiffcp.c
  23. index 6d96bb8..49c9d37 100644
  24. --- a/tools/tiffcp.c
  25. +++ b/tools/tiffcp.c
  26. @@ -1,4 +1,4 @@
  27. -/* $Id: tiffcp.c,v 1.59 2016-12-03 16:40:01 erouault Exp $ */
  28. +/* $Id: tiffcp.c,v 1.60 2016-12-03 16:50:02 erouault Exp $ */
  29. /*
  30. * Copyright (c) 1988-1997 Sam Leffler
  31. @@ -45,7 +45,6 @@
  32. #include <string.h>
  33. #include <ctype.h>
  34. -#include <assert.h>
  35. #ifdef HAVE_UNISTD_H
  36. # include <unistd.h>
  37. @@ -1393,7 +1392,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
  38. status = 0;
  39. goto done;
  40. }
  41. - assert( bps % 8 == 0 );
  42. + if( (bps % 8) != 0 )
  43. + {
  44. + TIFFError(TIFFFileName(in), "Error, cannot handle BitsPerSample that is not a multiple of 8");
  45. + status = 0;
  46. + goto done;
  47. + }
  48. bytes_per_sample = bps/8;
  49. for (row = 0; row < imagelength; row += tl) {
  50. @@ -1584,7 +1588,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
  51. _TIFFfree(obuf);
  52. return 0;
  53. }
  54. - assert( bps % 8 == 0 );
  55. + if( (bps % 8) != 0 )
  56. + {
  57. + TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8");
  58. + _TIFFfree(obuf);
  59. + return 0;
  60. + }
  61. bytes_per_sample = bps/8;
  62. for (row = 0; row < imagelength; row += tl) {