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.

63 lines
1.9 KiB

  1. commit b34209fede77aa203cd5adcd9638ccc70731a50f
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 16:40:01 2016 +0000
  4. * tools/tiffcp.c: fix uint32 underflow/overflow that can cause heap-based
  5. buffer overflow.
  6. Reported by Agostino Sarubbo.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610
  8. diff --git a/ChangeLog b/ChangeLog
  9. index 94be038..8ee76c0 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: fix uint32 underflow/overflow that can cause heap-based
  15. + buffer overflow.
  16. + Reported by Agostino Sarubbo.
  17. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610
  18. +
  19. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  20. +
  21. * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
  22. missing.
  23. Reported by Agostino Sarubbo.
  24. diff --git a/tools/tiffcp.c b/tools/tiffcp.c
  25. index 142cbb0..6d96bb8 100644
  26. --- a/tools/tiffcp.c
  27. +++ b/tools/tiffcp.c
  28. @@ -1,4 +1,4 @@
  29. -/* $Id: tiffcp.c,v 1.58 2016-12-03 15:44:15 erouault Exp $ */
  30. +/* $Id: tiffcp.c,v 1.59 2016-12-03 16:40:01 erouault Exp $ */
  31. /*
  32. * Copyright (c) 1988-1997 Sam Leffler
  33. @@ -1163,7 +1163,7 @@ bad:
  34. static void
  35. cpStripToTile(uint8* out, uint8* in,
  36. - uint32 rows, uint32 cols, int outskew, int inskew)
  37. + uint32 rows, uint32 cols, int outskew, int64 inskew)
  38. {
  39. while (rows-- > 0) {
  40. uint32 j = cols;
  41. @@ -1320,7 +1320,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
  42. tdata_t tilebuf;
  43. uint32 imagew = TIFFScanlineSize(in);
  44. uint32 tilew = TIFFTileRowSize(in);
  45. - int iskew = imagew - tilew;
  46. + int64 iskew = (int64)imagew - (int64)tilew;
  47. uint8* bufp = (uint8*) buf;
  48. uint32 tw, tl;
  49. uint32 row;
  50. @@ -1348,7 +1348,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
  51. status = 0;
  52. goto done;
  53. }
  54. - if (colb + tilew > imagew) {
  55. + if (colb > iskew) {
  56. uint32 width = imagew - colb;
  57. uint32 oskew = tilew - width;
  58. cpStripToTile(bufp + colb,