summaryrefslogtreecommitdiff
path: root/libtiff/tif_write.c
Commit message (Collapse)AuthorAgeFilesLines
* Reformatting in libtiff/ using 'pre-commit run'pre-commit run by Even Rouault2022-12-081-636/+674
|
* Remove vim/emacs formatting footersEven Rouault2022-12-081-9/+0
|
* TIFFWriteRawStrip(): restore capabilities to append data in the current ↵Even Rouault2022-11-291-3/+6
| | | | | | strip (fixes #489) This fixes a regression of libtiff 4.4.0
* Convert uses of _TIFFmalloc/realloc/calloc/free to the Ext functionsEven Rouault2022-11-231-12/+12
|
* Add reentrant error functionsLaramie Leavitt2022-11-081-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, libtiff relied on global error handlers, which is problematic when libtiff used by multiple independent libraries from within the same process, as they may unwittingly clobber the error handling, introduce race conditions when setting handlers, or otherwise have unintended side effects. This change adds error handlers to the TIFF struct, which are used preferentially when available. The error handlers are invoked when the re-entrant error functions are called: void TIFFErrorExtR(TIFF*, const char* module, const char* fmt, ...) void TIFFWarningExtR(TIFF*, const char* module, const char* fmt, ...) The handlers have a similar signature to the existing extended handlers, additionally returning an int: int TIFFErrorHandlerExtR(thandle_t, const char*, const char*, va_list) thandle_t is the userdata passed to TIFFOpen When the handler returns 1, the global handlers are not called. Custom error/warning handlers may be installed on a per-file basis by calling the Set functions: TIFF* tif = TIFFOpen(...); TIFFSetErrorHandlerExtR(tif, MyErrorHandler); TIFFSetWarningHandlerExtR(tif, MyWarningHandler); Additionally, the callsites to TIFFErrorExt and TIFFWarningExt have been updated to call the reentrant versions.
* Presetting of default tag values extended (e.g. PlanarConfig). (fixes #449)Su Laus2022-08-161-16/+0
|
* TIFFAppendToStrip(): fix rewrite-in-place logic (fixes #309)Even Rouault2021-12-041-13/+18
| | | | Properly reset tif_curoff when writing strips/tiles
* TIFFAppendToStrip(): fix rewrite-in-place logicEven Rouault2021-09-231-14/+96
| | | | | | reproducable in particular with packbits compression. Fixes https://github.com/OSGeo/gdal/issues/4538
* Use standard C99 integer typesRoger Leigh2021-01-211-55/+55
|
* Add support for optional building against libdeflate for faster Zip/Deflate ↵Even Rouault2020-10-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | compression/decompression. So we can have 2 kind of builds with the Zip/Deflate codec: - zlib only - zlib + libdeflate Speed improvements in the 35%-50% range can be expected when libdeflate is used. Compression level up to 12 is now supported (capped to 9 when zlib is used). Still requires zlib for situations where libdeflate cannot be used (that is for scanline access, since libdeflate has no streaming mode) Pseudo-tag TIFFTAG_DEFLATE_SUBCODEC=DEFLATE_SUBCODEC_ZLIB/DEFLATE_SUBCODEC_LIBDEFLATE is added to control which subcodec (zlib or libdeflate) should be used (it defaults of course to libdeflate, when it is available). This is mostly aimed at being used on the writing side, to be able to reproduce output of previous libtiff versions at a binary level, in situations where this would be really needed. Or as a safety belt in case there would be unforeseen issues with using libdeflate. It can be used to know when libdeflate is available at runtime (DEFLATE_SUBCODEC_LIBDEFLATE will be the default value in that situation). Of course, deflate codestreams produced by libdeflate can be read by zlib, and vice-versa.
* TIFFSetupStrips: enforce 2GB limitation of Strip/Tile Offsets/ByteCounts arraysEven Rouault2020-02-011-0/+7
| | | | | TIFFWriteDirectoryTagData() has an assertion that checks that the arrays are not larger than 2GB. So error out earlier if in that situation.
* TIFFWriteCheck(): call TIFFForceStrileArrayWriting() when needed (should ↵Even Rouault2019-07-091-0/+14
| | | | have gone with eaeca6274ae71cdfaeb9f673b6fb0f3cfc0e6ce5) (master only)
* Replace 'stripped' by 'striped' in error messagesEven Rouault2019-05-251-1/+1
|
* Make defer strile offset/bytecount loading available at runtimeEven Rouault2019-05-101-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and add per-strile offset/bytecount loading capabilities. Part of this commit makes the behaviour that was previously met when libtiff was compiled with -DDEFER_STRILE_LOAD available for default builds when specifying the new 'D' (Deferred) TIFFOpen() flag. In that mode, the [Tile/Strip][ByteCounts/Offsets] arrays are only loaded when first accessed. This can speed-up the opening of files stored on the network when just metadata retrieval is needed. This mode has been used for years by the GDAL library when compiled with its embeded libtiff copy. To avoid potential out-of-tree code (typically codecs) that would use the td_stripbytecount and td_stripoffset array inconditionnaly assuming they have been loaded, those have been suffixed with _p (for protected). The use of the new functions mentionned below is then recommended. Another addition of this commit is the capability of loading only the values of the offset/bytecount of the strile of interest instead of the whole array. This is enabled with the new 'O' (Ondemand) flag of TIFFOpen() (which implies 'D'). That behaviour has also been used by GDAL, which hacked into the td_stripoffset/td_stripbytecount arrays directly. The new code added in the _TIFFFetchStrileValue() and _TIFFPartialReadStripArray() internal functions is mostly a port of what was in GDAL GTiff driver previously. Related to that, the public TIFFGetStrileOffset[WithErr]() and TIFFGetStrileByteCount[WithErr]() functions have been added to API. They are of particular interest when using sparse files (with offset == bytecount == 0) and you want to detect if a strile is present or not without decompressing the data, or updating an existing sparse file. They will also be used to enable a future enhancement where client code can entirely skip bytecount loading in some situtations A new test/defer_strile_loading.c test has been added to test the above capabilities.
* TIFFWriteEncodedStrip/TIFFWriteEncodedTile: fix rewriting of LZW-compressed dataEven Rouault2019-04-111-37/+35
| | | | | | | | Fixes https://github.com/OSGeo/gdal/issues/1439 When rewriting a LZW tile/strip whose existing size is very close to a multiple of 1024 bytes (and larger than 8192 bytes) with compressed data that is larger, the new data was not placed at the end of the file, causing corruption.
* TIFFSetupStrips(): avoid potential uint32 overflow on 32-bit systems with ↵Even Rouault2018-08-151-2/+4
| | | | large number of strips. Probably relates to http://bugzilla.maptools.org/show_bug.cgi?id=2788 / CVE-2018-10779
* Remove all $Id and $Headers comments with CVS versionsEven Rouault2017-11-301-2/+0
|
* * libtiff/tif_write.c: fix misleading indentation as warned by GCC.Even Rouault2016-12-031-16/+16
|
* * tools/tiffcrop.c: fix various out-of-bounds write vulnerabilitiesEven Rouault2016-09-231-1/+8
| | | | | | | | | | | | | | | | | | | | | | in heap or stack allocated buffers. Reported as MSVR 35093, MSVR 35096 and MSVR 35097. Discovered by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team. * tools/tiff2pdf.c: fix out-of-bounds write vulnerabilities in heap allocate buffer in t2p_process_jpeg_strip(). Reported as MSVR 35098. Discovered by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team. * libtiff/tif_pixarlog.c: fix out-of-bounds write vulnerabilities in heap allocated buffers. Reported as MSVR 35094. Discovered by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team. * libtiff/tif_write.c: fix issue in error code path of TIFFFlushData1() that didn't reset the tif_rawcc and tif_rawcp members. I'm not completely sure if that could happen in practice outside of the odd behaviour of t2p_seekproc() of tiff2pdf). The report points that a better fix could be to check the return value of TIFFFlushData1() in places where it isn't done currently, but it seems this patch is enough. Reported as MSVR 35095. Discovered by Axel Souchet & Vishal Chauhan & Suha Can from the MSRC Vulnerabilities & Mitigations team.
* * libtiff/tif_read.c: make TIFFReadEncodedStrip() andEven Rouault2016-07-031-4/+38
| | | | | | | | | TIFFReadEncodedTile() directly use user provided buffer when no compression (and other conditions) to save a memcpy(). * libtiff/tif_write.c: make TIFFWriteEncodedStrip() and TIFFWriteEncodedTile() directly use user provided buffer when no compression to save a memcpy().
* * libtiff/tif_write.c: TIFFWriteEncodedStrip() and TIFFWriteEncodedTile()Even Rouault2015-12-121-3/+3
| | | | | | should return -1 in case of failure of tif_encodestrip() as documented * libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in case of failure so that the above mentionned functions detect the error.
* (TIFFWriteScanline): Fix Coverity 715979 "Division or modulo byBob Friesenhahn2015-06-071-1/+5
| | | | zero".
* (TIFFWriteRawStrip): Fix Coverity 715978 "Division or modulo byBob Friesenhahn2015-06-071-1/+5
| | | | zero".
* (TIFFWriteEncodedTile): Fix Coverity 715976 and 715977 "DivisionBob Friesenhahn2015-06-071-5/+14
| | | | or modulo by zero".
* * libtiff/tif_write.c (TIFFWriteEncodedStrip): Fix Coverity 715975Bob Friesenhahn2015-06-071-1/+6
| | | | | * libtiff/tif_read.c (TIFFStartTile): Fix Coverity 715973 and 715974 "Division or modulo by zero".
* avoid type cast warningsFrank Warmerdam2013-01-181-5/+5
|
* fix bug rewriting image tiles in a compressed file (gdal #4771)Frank Warmerdam2012-08-131-9/+31
|
* implement optional support for deferred strip/tile offset/size loadingFrank Warmerdam2011-02-181-1/+3
|
* * libtiff/tif_aux.c (_TIFFCheckRealloc): Improve error message soBob Friesenhahn2010-03-101-1/+8
| | | | | that it is clearly a memory allocation error message, and also includes the size of the allocation request.
* do not override planar config if set (#2057)Frank Warmerdam2009-06-031-2/+3
|
* * libtiff/tiffio.h: Undeprecate toff_t and restore its use in theBob Friesenhahn2008-12-301-2/+2
| | | | TIFFClientOpen() callback and other external function definitions.
* Keep track of TIFF_DIRTYSTRIP separately from TIFF_DIRTYDIRECT to indicateFrank Warmerdam2007-12-311-2/+11
| | | | | | | | | | | | that the strip offset/size values are dirty but nothing else about the directory is dirty. In flush handle "just stripmaps dirty" as a special case that just rewrites these values without otherwise modifying the directory on disk using TIFFRewriteField(). We also modify logic so that in update mode the directory is not marked dirty on read, but only when something is changed. This means we need to keep track of updates to the stripmap stuff in TIFFAppendToStrip().
* introduce TIFF_BUF4WRITE flag to mark rawcc buffer as for writingFrank Warmerdam2007-11-231-2/+9
|
* avoid corruption risk with write-in-same-location logicFrank Warmerdam2007-11-021-51/+40
|
* changed some more incorrect %lud printf flags to %luJoris Van Damme2007-10-011-2/+2
|
* added maximum file size overflow check to avoid writing bad classictiff > 4 gigJoris Van Damme2007-07-111-58/+65
|
* BigTIFF upgrade: type restoration - not so messy anymoreJoris Van Damme2007-06-121-16/+16
|
* BigTIFF upgrade in progress - widespread temp mess - does not compile nowJoris Van Damme2007-04-041-57/+66
|
* BigTIFF upgrade in progress - widespread temp mess - does not compile nowJoris Van Damme2007-03-311-115/+105
|
* BigTIFF upgrade in progress - widespread temp mess - does not compile nowJoris Van Damme2007-03-311-126/+128
|
* BigTIFF upgrade in progress - widespread temp mess - does not compile nowJoris Van Damme2007-03-281-10/+10
|
* clear sorted flag if we move a strip/tile - bug 1359Frank Warmerdam2006-11-201-61/+62
|
* Small code rearrangement in TIFFWriteScanline() to avoid crash as per bugAndrey Kiselev2006-02-271-15/+13
| | | | http://bugzilla.remotesensing.org/show_bug.cgi?id=1081.
* *** empty log message ***Joris Van Damme2005-12-211-16/+16
|
* Fixed setting of planar config as per bug report from Joris.Frank Warmerdam2005-10-151-2/+2
|
* Do not check the PlanarConfiguration field in the TIFFWriteCheck() function inAndrey Kiselev2005-07-211-6/+16
| | | | case of single band images (as per TIFF spec).
* Fixed wrong if() statement in TIFFAppendToStrip() function as per bugAndrey Kiselev2004-11-051-2/+3
| | | | http://bugzilla.remotesensing.org/show_bug.cgi?id=660
* Handle the zero strip/tile sizes properly (Dmitry V. Levin, Marcus Meissner).Andrey Kiselev2004-10-121-2/+2
|
* Added checks for failed memory allocations andinteger overflowsAndrey Kiselev2004-10-021-2/+5
| | | | (Dmitry V. Levin).
* Optimize checking for the strip bounds.Andrey Kiselev2004-09-261-9/+21
|