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.

74 lines
2.8 KiB

  1. commit 9991b31a7c651e7b87a3ccd73b3dc5c67dcfdd60
  2. Author: erouault <erouault>
  3. Date: Sat Dec 3 15:30:31 2016 +0000
  4. * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) is called,
  5. limit the return number of inks to SamplesPerPixel, so that code that parses
  6. ink names doesn't go past the end of the buffer.
  7. Reported by Agostino Sarubbo.
  8. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599
  9. Reported by Agostino Sarubbo.
  10. diff --git a/ChangeLog b/ChangeLog
  11. index 0d7b12d..fb9fc0e 100644
  12. --- a/ChangeLog
  13. +++ b/ChangeLog
  14. @@ -1,5 +1,13 @@
  15. 2016-12-03 Even Rouault <even.rouault at spatialys.com>
  16. + * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) is called,
  17. + limit the return number of inks to SamplesPerPixel, so that code that parses
  18. + ink names doesn't go past the end of the buffer.
  19. + Reported by Agostino Sarubbo.
  20. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599
  21. +
  22. +2016-12-03 Even Rouault <even.rouault at spatialys.com>
  23. +
  24. * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
  25. missing.
  26. Reported by Agostino Sarubbo.
  27. diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
  28. index ad21655..2574e74 100644
  29. --- a/libtiff/tif_dir.c
  30. +++ b/libtiff/tif_dir.c
  31. @@ -1,4 +1,4 @@
  32. -/* $Id: tif_dir.c,v 1.127 2016-10-25 21:35:15 erouault Exp $ */
  33. +/* $Id: tif_dir.c,v 1.128 2016-12-03 15:30:31 erouault Exp $ */
  34. /*
  35. * Copyright (c) 1988-1997 Sam Leffler
  36. @@ -854,6 +854,32 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
  37. if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
  38. return 0;
  39. + if( tag == TIFFTAG_NUMBEROFINKS )
  40. + {
  41. + int i;
  42. + for (i = 0; i < td->td_customValueCount; i++) {
  43. + uint16 val;
  44. + TIFFTagValue *tv = td->td_customValues + i;
  45. + if (tv->info->field_tag != tag)
  46. + continue;
  47. + val = *(uint16 *)tv->value;
  48. + /* Truncate to SamplesPerPixel, since the */
  49. + /* setting code for INKNAMES assume that there are SamplesPerPixel */
  50. + /* inknames. */
  51. + /* Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599 */
  52. + if( val > td->td_samplesperpixel )
  53. + {
  54. + TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
  55. + "Truncating NumberOfInks from %u to %u",
  56. + val, td->td_samplesperpixel);
  57. + val = td->td_samplesperpixel;
  58. + }
  59. + *va_arg(ap, uint16*) = val;
  60. + return 1;
  61. + }
  62. + return 0;
  63. + }
  64. +
  65. /*
  66. * We want to force the custom code to be used for custom
  67. * fields even if the tag happens to match a well known