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.

84 lines
3.3 KiB

  1. From 6173a57d39e04d68b139f8c1aa499a24dbe74ba1 Mon Sep 17 00:00:00 2001
  2. From: Even Rouault <even.rouault@spatialys.com>
  3. Date: Fri, 30 Jun 2017 17:29:44 +0000
  4. Subject: [PATCH] * libtiff/tif_dirwrite.c: in
  5. TIFFWriteDirectoryTagCheckedXXXX() functions associated with LONG8/SLONG8
  6. data type, replace assertion that the file is BigTIFF, by a non-fatal error.
  7. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712 Reported by team
  8. OWL337
  9. ---
  10. ChangeLog | 8 ++++++++
  11. libtiff/tif_dirwrite.c | 20 ++++++++++++++++----
  12. 2 files changed, 24 insertions(+), 4 deletions(-)
  13. diff --git a/ChangeLog b/ChangeLog
  14. index 6f085e09..77a64385 100644
  15. --- a/ChangeLog
  16. +++ b/ChangeLog
  17. @@ -1,5 +1,13 @@
  18. 2017-06-30 Even Rouault <even.rouault at spatialys.com>
  19. + * libtiff/tif_dirwrite.c: in TIFFWriteDirectoryTagCheckedXXXX()
  20. + functions associated with LONG8/SLONG8 data type, replace assertion that
  21. + the file is BigTIFF, by a non-fatal error.
  22. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712
  23. + Reported by team OWL337
  24. +
  25. +2017-06-30 Even Rouault <even.rouault at spatialys.com>
  26. +
  27. * libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedStripAndAllocBuffer()
  28. function, variant of TIFFReadEncodedStrip() that allocates the
  29. decoded buffer only after a first successful TIFFFillStrip(). This avoids
  30. diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
  31. index 2967da58..8d6686ba 100644
  32. --- a/libtiff/tif_dirwrite.c
  33. +++ b/libtiff/tif_dirwrite.c
  34. @@ -2111,7 +2111,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui
  35. {
  36. uint64 m;
  37. assert(sizeof(uint64)==8);
  38. - assert(tif->tif_flags&TIFF_BIGTIFF);
  39. + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
  40. + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF");
  41. + return(0);
  42. + }
  43. m=value;
  44. if (tif->tif_flags&TIFF_SWAB)
  45. TIFFSwabLong8(&m);
  46. @@ -2124,7 +2127,10 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di
  47. {
  48. assert(count<0x20000000);
  49. assert(sizeof(uint64)==8);
  50. - assert(tif->tif_flags&TIFF_BIGTIFF);
  51. + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
  52. + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF");
  53. + return(0);
  54. + }
  55. if (tif->tif_flags&TIFF_SWAB)
  56. TIFFSwabArrayOfLong8(value,count);
  57. return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value));
  58. @@ -2136,7 +2142,10 @@ TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u
  59. {
  60. int64 m;
  61. assert(sizeof(int64)==8);
  62. - assert(tif->tif_flags&TIFF_BIGTIFF);
  63. + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
  64. + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","SLONG8 not allowed for ClassicTIFF");
  65. + return(0);
  66. + }
  67. m=value;
  68. if (tif->tif_flags&TIFF_SWAB)
  69. TIFFSwabLong8((uint64*)(&m));
  70. @@ -2149,7 +2158,10 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
  71. {
  72. assert(count<0x20000000);
  73. assert(sizeof(int64)==8);
  74. - assert(tif->tif_flags&TIFF_BIGTIFF);
  75. + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
  76. + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","SLONG8 not allowed for ClassicTIFF");
  77. + return(0);
  78. + }
  79. if (tif->tif_flags&TIFF_SWAB)
  80. TIFFSwabArrayOfLong8((uint64*)value,count);
  81. return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value));