|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Compute checked sizes/offsets and bounded scalar conversions. More...
Functions | |
| uint32_t | _TIFFMultiply32 (TIFF *tif, uint32_t first, uint32_t second, const char *where) |
| Multiply two unsigned values with an overflow check. | |
| uint32_t | _TIFFParseUInt32 (const char *str, uint32_t default_value, uint32_t max_value) |
| Parse a decimal unsigned integer with a fallback value. | |
| uint64_t | _TIFFMultiply64 (TIFF *tif, uint64_t first, uint64_t second, const char *where) |
| Multiply two unsigned values with an overflow check. | |
| uint64_t | _TIFFAdd64 (TIFF *tif, uint64_t first, uint64_t second, const char *where) |
| Check and add two unsigned operands. | |
| tmsize_t | _TIFFMultiplySSize (TIFF *tif, tmsize_t first, tmsize_t second, const char *where) |
| Check and multiply two signed-size operands. | |
| tmsize_t | _TIFFAddSSize (TIFF *tif, tmsize_t first, tmsize_t second, const char *where) |
| Check and add two signed-size operands. | |
| tmsize_t | _TIFFCastUInt64ToSSize (TIFF *tif, uint64_t val, const char *module) |
| Convert an unsigned 64-bit value after checking the destination range. | |
| uint32_t | _TIFFCastUInt64ToUInt32 (TIFF *tif, uint64_t val, const char *module) |
| Convert an unsigned 64-bit value after checking the destination range. | |
| uint32_t | _TIFFMultiply32Ext (TIFF *tif, uint32_t first, uint32_t second, const char *where, bool *pOverflowed) |
| Multiply two unsigned values with an overflow check, and record an overflow in a caller-provided flag. | |
| uint64_t | _TIFFAdd64Ext (TIFF *tif, uint64_t first, uint64_t second, const char *where, bool *pOverflowed) |
| Check and add two unsigned operands, and record an overflow in a caller-provided flag. | |
| uint32_t | _TIFFCastUInt64ToUInt32Ext (TIFF *tif, uint64_t val, const char *module, bool *pOverflowed) |
| Convert an unsigned 64-bit value after checking the destination range, and record a rejection in a caller-provided flag. | |
| uint64_t | _TIFFComputeRowSize64 (TIFF *tif, uint32_t width, uint16_t spp, uint16_t bps, const char *where) |
| Compute a byte-rounded row size from width and sample geometry. | |
| tmsize_t | _TIFFComputeRowOffset (TIFF *tif, tmsize_t rowstride, uint32_t row, const char *where) |
| Compute a checked byte offset for a row in a memory raster. | |
| uint64_t | _TIFFComputeBitOffset (TIFF *tif, uint32_t col, uint16_t spp, uint16_t bps, const char *where) |
| Compute a checked packed-sample column offset in bits. | |
| float | _TIFFClampDoubleToFloat (double val) |
| Clamp a double to the finite float range before conversion. | |
| uint32_t | _TIFFClampDoubleToUInt32 (double val) |
| Clamp and truncate a double to an unsigned 32-bit value. | |
| int | _TIFFSeekOK (TIFF *tif, toff_t off) |
| Test whether an allowed absolute client seek reaches its target. | |
Compute checked sizes/offsets and bounded scalar conversions.
|
extern |
Check and add two unsigned operands.
Unsigned operands. A rejection emits an error only when both tif and where are non-NULL; otherwise it returns zero silently. Uses bounds checks before the arithmetic operation. Does not allocate or change handle fields; diagnostics can have callback-defined effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | first | First operand. |
| [in] | second | Second operand. |
| [in] | where | Optional borrowed diagnostic context name. |
Definition at line 85 of file tif_aux.c.
References _TIFFAdd64Ext().
Referenced by JPEGRawBytesPerClumpLine(), TIFFComputeStrip(), TIFFSeek(), and TIFFWriteScanline().
|
extern |
Check and add two unsigned operands, and record an overflow in a caller-provided flag.
Behaves as _TIFFAdd64(): a result beyond UINT64_MAX emits an error only when both tif and where are non-NULL; otherwise it returns zero silently. On overflow, also sets *pOverflowed to true when pOverflowed is not NULL. The flag is never reset to false, so several operations can share one flag that is tested once. Does not allocate or change handle fields; diagnostics can have callback-defined effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | first | First operand. |
| [in] | second | Second operand. |
| [in] | where | Optional borrowed diagnostic context name. |
| [out] | pOverflowed | Overflow flag, or NULL; set to true on overflow and left unchanged otherwise. |
Definition at line 180 of file tif_aux.c.
References TIFFErrorExtR().
Referenced by _TIFFAdd64(), and _TIFFComputeTileExt().
Check and add two signed-size operands.
Both operands must be nonnegative; zero is accepted. A rejection emits an error only when both tif and where are non-NULL; otherwise it returns zero silently. Uses bounds checks before the arithmetic operation. Does not allocate or change handle fields; diagnostics can have callback-defined effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | first | First operand. |
| [in] | second | Second operand. |
| [in] | where | Optional borrowed diagnostic context name. |
Definition at line 116 of file tif_aux.c.
References TIFF_TMSIZE_T_MAX, and TIFFErrorExtR().
Convert an unsigned 64-bit value after checking the destination range.
Range rejection reports an error only when both tif and module are non-NULL. Otherwise it fails silently with zero. Does not allocate, retain pointers, or change handle state except for diagnostic callback effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | val | Unsigned value to convert. |
| [in] | module | Optional borrowed diagnostic module name. |
Definition at line 140 of file tif_aux.c.
References TIFF_TMSIZE_T_MAX, and TIFFErrorExtR().
Referenced by JBIGEncode(), JPEGDecodeRaw(), JPEGRawBytesPerClumpLine(), PredictorSetup(), TIFFRasterScanlineSize(), TIFFReadRawStrip(), TIFFReadRawTile(), TIFFScanlineSize(), TIFFStripSize(), TIFFTileRowSize(), TIFFTileSize(), TIFFVStripSize(), TIFFVTileSize(), TIFFWriteDirectoryTagColormap(), and TIFFWriteDirectoryTagTransferfunction().
|
extern |
Convert an unsigned 64-bit value after checking the destination range.
Range rejection reports an error only when both tif and module are non-NULL. Otherwise it fails silently with zero. Does not allocate, retain pointers, or change handle state except for diagnostic callback effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | val | Unsigned value to convert. |
| [in] | module | Optional borrowed diagnostic module name. |
Definition at line 153 of file tif_aux.c.
References _TIFFCastUInt64ToUInt32Ext().
Referenced by TIFFComputeStrip(), TIFFSeek(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagTransferfunction(), and TIFFWriteScanline().
|
extern |
Convert an unsigned 64-bit value after checking the destination range, and record a rejection in a caller-provided flag.
Behaves as _TIFFCastUInt64ToUInt32(): range rejection reports an error only when both tif and module are non-NULL; otherwise it fails silently with zero. On rejection, also sets *pOverflowed to true when pOverflowed is not NULL. The flag is never reset to false, so several operations can share one flag that is tested once. Does not allocate, retain pointers, or change handle state except for diagnostic callback effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | val | Unsigned value to convert. |
| [in] | module | Optional borrowed diagnostic module name. |
| [out] | pOverflowed | Overflow flag, or NULL; set to true if val exceeds UINT32_MAX and left unchanged otherwise. |
Definition at line 197 of file tif_aux.c.
References TIFFErrorExtR().
Referenced by _TIFFCastUInt64ToUInt32(), and _TIFFComputeTileExt().
|
extern |
Clamp a double to the finite float range before conversion.
Performs no allocation, handle mutation, ownership transfer, or library diagnostics. Normal floating-point rounding/exception behaviour applies; NaN payload preservation is not promised.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 602 of file tif_aux.c.
Referenced by _TIFFVSetField(), and TIFFWriteDirectoryTagSampleformatArray().
|
extern |
Clamp and truncate a double to an unsigned 32-bit value.
Performs no allocation, ownership transfer, handle mutation, or library diagnostics. Normal floating-point exception behaviour applies; the NaN-to-maximum rule is intentional current behaviour.
| [in] | val | Input double, including infinities or NaN. |
|
extern |
Compute a checked packed-sample column offset in bits.
Uses _TIFFMultiply64() for the two products and its diagnostic rules. Does not round to a byte boundary or validate a buffer extent. Does not allocate or change handle fields.
| [in] | tif | Optional diagnostic handle. |
| [in] | col | Zero-based pixel column. |
| [in] | spp | Samples per pixel. |
| [in] | bps | Bits per sample. |
| [in] | where | Non-NULL diagnostic context if multiplication overflow is possible. |
Definition at line 221 of file tif_aux.c.
References _TIFFMultiply64().
|
extern |
Compute a checked byte offset for a row in a memory raster.
Delegates nonzero rows to _TIFFMultiplySSize(), including its conditional diagnostics. On narrower hosts, the row conversion must itself be representable. Does not allocate, validate an actual buffer extent, or change handle fields.
| [in] | tif | Optional diagnostic handle. |
| [in] | rowstride | Positive bytes per row when row is nonzero. |
| [in] | row | Zero-based row; must be representable by tmsize_t when nonzero. |
| [in] | where | Optional borrowed diagnostic context. |
Definition at line 213 of file tif_aux.c.
References _TIFFMultiplySSize().
|
extern |
Compute a byte-rounded row size from width and sample geometry.
Rounds the complete row once, rather than each pixel/sample. Zero geometry returns zero without a direct diagnostic. Multiplication rejection uses _TIFFMultiply64() reporting rules. This is a generic packed-row computation, not a complete codec/YCbCr layout rule. No allocation, ownership transfer, or handle-field mutation occurs.
| [in] | tif | Optional diagnostic handle used by checked multiplication. |
| [in] | width | Row width in pixels. |
| [in] | spp | Samples per pixel. |
| [in] | bps | Bits per sample. |
| [in] | where | Non-NULL diagnostic context if multiplication overflow is possible. |
Definition at line 234 of file tif_aux.c.
References _TIFFMultiply64(), and TIFFhowmany8_64.
|
extern |
Multiply two unsigned values with an overflow check.
Checks division bounds before multiplying. Overflow always invokes TIFFErrorExtR(), including when tif is NULL; where is also formatted as a string, so it must be valid on that path. Does not allocate, mutate handle fields, retain arguments, or perform I/O except through diagnostic callbacks.
| [in] | tif | Diagnostic handle, or NULL for global diagnostic dispatch. |
| [in] | first | First factor. |
| [in] | second | Second factor. |
| [in] | where | Non-NULL diagnostic context name when an overflow can occur. |
Definition at line 40 of file tif_aux.c.
References _TIFFMultiply32Ext().
Referenced by LERCPostEncode(), LERCPreDecode(), OJPEGReadHeaderInfo(), OJPEGWriteHeaderInfo(), SetupBuffers(), TIFFNumberOfStrips(), and TIFFNumberOfTiles().
|
extern |
Multiply two unsigned values with an overflow check, and record an overflow in a caller-provided flag.
Behaves as _TIFFMultiply32(): checks division bounds before multiplying, and overflow always invokes TIFFErrorExtR(), including when tif is NULL; where is also formatted as a string, so it must be valid on that path. On overflow, also sets *pOverflowed to true when pOverflowed is not NULL. The flag is never reset to false, so several operations can share one flag that is tested once. Does not allocate, mutate handle fields, retain arguments, or perform I/O except through diagnostic callbacks.
| [in] | tif | Diagnostic handle, or NULL for global diagnostic dispatch. |
| [in] | first | First factor. |
| [in] | second | Second factor. |
| [in] | where | Non-NULL diagnostic context name when an overflow can occur. |
| [out] | pOverflowed | Overflow flag, or NULL; set to true on overflow and left unchanged otherwise. |
Definition at line 166 of file tif_aux.c.
References TIFFErrorExtR().
Referenced by _TIFFComputeTileExt(), and _TIFFMultiply32().
|
extern |
Multiply two unsigned values with an overflow check.
Checks division bounds before multiplying. Overflow always invokes TIFFErrorExtR(), including when tif is NULL; where is also formatted as a string, so it must be valid on that path. Does not allocate, mutate handle fields, retain arguments, or perform I/O except through diagnostic callbacks.
| [in] | tif | Diagnostic handle, or NULL for global diagnostic dispatch. |
| [in] | first | First factor. |
| [in] | second | Second factor. |
| [in] | where | Non-NULL diagnostic context name when an overflow can occur. |
Definition at line 46 of file tif_aux.c.
References TIFFErrorExtR().
Referenced by _TIFFComputeBitOffset(), _TIFFComputeRowSize64(), _TIFFStrileSize64(), JBIGEncode(), JPEGDecodeRaw(), JPEGRawBytesPerClumpLine(), PredictorSetup(), TIFFComputeStrip(), TIFFRasterScanlineSize64(), TIFFScanlineSize64(), TIFFSeek(), TIFFTileRowSize64(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagTransferfunction(), and TIFFWriteScanline().
|
extern |
Check and multiply two signed-size operands.
Both operands must be positive; zero and negatives are rejected. A rejection emits an error only when both tif and where are non-NULL; otherwise it returns zero silently. Uses bounds checks before the arithmetic operation. Does not allocate or change handle fields; diagnostics can have callback-defined effects.
| [in] | tif | Optional diagnostic handle. |
| [in] | first | First operand. |
| [in] | second | Second operand. |
| [in] | where | Optional borrowed diagnostic context name. |
Definition at line 91 of file tif_aux.c.
References TIFF_TMSIZE_T_MAX, and TIFFErrorExtR().
Referenced by _TIFFCheckRealloc(), _TIFFComputeRowOffset(), _TIFFVSetField(), gtStripSeparate(), gtTileSeparate(), multiply_ms(), multiply_ms(), setByteArray(), setDoubleArrayOneValue(), and TIFFGrowStrips().
|
extern |
Parse a decimal unsigned integer with a fallback value.
Accepts optional leading C whitespace and an optional '+', then one or more decimal digits and nothing else; trailing characters, including whitespace, are rejected. The value is accumulated with an overflow check against max_value. Used for environment-variable tuning limits. Does not allocate, retain str, use errno, or emit diagnostics.
| [in] | str | NUL-terminated text to parse, or NULL. |
| [in] | default_value | Value returned when str is NULL, malformed, or out of range; it need not be at most max_value. |
| [in] | max_value | Largest accepted value. |
Definition at line 58 of file tif_aux.c.
Referenced by TIFFFetchStripThing(), and TIFFjpeg_start_decompress().
Test whether an allowed absolute client seek reaches its target.
Offsets above the bound are rejected without seeking. Otherwise invokes one SEEK_SET callback. May change client position/state and inherits its failure conventions; a zero-returning native Windows seek failure can be confused with a successful seek to zero. Adds no diagnostics, allocation, or ownership transfer.
| [in,out] | tif | Non-NULL live TIFF handle with seek callback. |
| [in] | off | Requested absolute byte position. |
Definition at line 620 of file tif_aux.c.
References TIFFSeekFile.