LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
Entry decoding and reader helpers

Fetch, convert, validate, and recover parsed directory entries. More...

Collaboration diagram for Entry decoding and reader helpers:

Data Structures

union  _UInt64Aligned_t
 Provide aligned scalar and byte views of eight raw bytes. More...
 

Macros

#define FAILED_FII   ((uint32_t)-1)
 Represent a missing field-table index with UINT32_MAX.
 
#define TIFFCvtIEEEFloatToNative(tif, n, fp)
 Recognise already compatible float storage without conversion.
 
#define TIFFCvtIEEEDoubleToNative(tif, n, dp)
 Recognise already compatible double storage without conversion.
 
#define INITIAL_THRESHOLD   (1024 * 1024)
 Start progressive external-tag reads at one MiB on 64-bit hosts.
 
#define THRESHOLD_MULTIPLIER   10
 Grow progressive read requests by a factor of ten.
 
#define MAX_THRESHOLD
 Set the progressive read threshold cutoff to 1000 MiB.
 
#define MAX_SIZE_TAG_DATA   2147483647U
 Limit source and converted tag arrays to INT32_MAX bytes.
 

Typedefs

typedef union _UInt64Aligned_t UInt64Aligned_t
 Provide aligned scalar and byte views of eight raw bytes.
 

Enumerations

enum  TIFFReadDirEntryErr {
  TIFFReadDirEntryErrOk = 0 , TIFFReadDirEntryErrCount = 1 , TIFFReadDirEntryErrType = 2 , TIFFReadDirEntryErrIo = 3 ,
  TIFFReadDirEntryErrRange = 4 , TIFFReadDirEntryErrPsdif = 5 , TIFFReadDirEntryErrSizesan = 6 , TIFFReadDirEntryErrAlloc = 7
}
 Classify directory-entry decoding failures. More...
 

Functions

static uint64_t TIFFReadUInt64 (const uint8_t *value)
 Copy eight unaligned bytes into a native uint64_t value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryByte (TIFF *tif, TIFFDirEntry *direntry, uint8_t *value)
 Convert one directory value to uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyte (TIFF *tif, TIFFDirEntry *direntry, int8_t *value)
 Convert one directory value to int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryShort (TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
 Convert one directory value to uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySshort (TIFF *tif, TIFFDirEntry *direntry, int16_t *value)
 Convert one directory value to int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong (TIFF *tif, TIFFDirEntry *direntry, uint32_t *value)
 Convert one directory value to uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong (TIFF *tif, TIFFDirEntry *direntry, int32_t *value)
 Convert one directory value to int32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8 (TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
 Convert one directory value to uint64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8 (TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
 Convert one directory value to int64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat (TIFF *tif, TIFFDirEntry *direntry, float *value)
 Convert one directory value to float.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble (TIFF *tif, TIFFDirEntry *direntry, double *value)
 Convert one directory value to double.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8 (TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
 Convert one directory value to uint64_t directory offset.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc (TIFF *tif, uint64_t offset, tmsize_t size, void **pdest)
 Grow an owned buffer while reading an external value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit (TIFF *tif, TIFFDirEntry *direntry, uint32_t *count, uint32_t desttypesize, void **value, uint64_t maxcount)
 Fetch raw directory array bytes with checked size limits.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryArray (TIFF *tif, TIFFDirEntry *direntry, uint32_t *count, uint32_t desttypesize, void **value)
 Fetch raw directory array bytes with checked size limits.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray (TIFF *tif, TIFFDirEntry *direntry, uint8_t **value)
 Read a directory array as uint8_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray (TIFF *tif, TIFFDirEntry *direntry, int8_t **value)
 Read a directory array as int8_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray (TIFF *tif, TIFFDirEntry *direntry, uint16_t **value)
 Read a directory array as uint16_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray (TIFF *tif, TIFFDirEntry *direntry, int16_t **value)
 Read a directory array as int16_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray (TIFF *tif, TIFFDirEntry *direntry, uint32_t **value)
 Read a directory array as uint32_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray (TIFF *tif, TIFFDirEntry *direntry, int32_t **value)
 Read a directory array as int32_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit (TIFF *tif, TIFFDirEntry *direntry, uint64_t **value, uint64_t maxcount)
 Read a directory array as uint64_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array (TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
 Read a directory array as uint64_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array (TIFF *tif, TIFFDirEntry *direntry, int64_t **value)
 Read a directory array as int64_t elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray (TIFF *tif, TIFFDirEntry *direntry, float **value)
 Read a directory array as float elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray (TIFF *tif, TIFFDirEntry *direntry, double **value)
 Read a directory array as double elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array (TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
 Read a directory array as uint64_t directory offset elements.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort (TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
 Reduce equal per-sample short values to one scalar.
 
static void TIFFReadDirEntryCheckedByte (TIFF *tif, TIFFDirEntry *direntry, uint8_t *value)
 Read a prevalidated uint8_t value.
 
static void TIFFReadDirEntryCheckedSbyte (TIFF *tif, TIFFDirEntry *direntry, int8_t *value)
 Read a prevalidated int8_t value.
 
static void TIFFReadDirEntryCheckedShort (TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
 Read a prevalidated uint16_t value.
 
static void TIFFReadDirEntryCheckedSshort (TIFF *tif, TIFFDirEntry *direntry, int16_t *value)
 Read a prevalidated int16_t value.
 
static void TIFFReadDirEntryCheckedLong (TIFF *tif, TIFFDirEntry *direntry, uint32_t *value)
 Read a prevalidated uint32_t value.
 
static void TIFFReadDirEntryCheckedSlong (TIFF *tif, TIFFDirEntry *direntry, int32_t *value)
 Read a prevalidated int32_t value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8 (TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
 Read a prevalidated uint64_t value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8 (TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
 Read a prevalidated int64_t value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational (TIFF *tif, TIFFDirEntry *direntry, double *value)
 Read a prevalidated srational value.
 
static void TIFFReadDirEntryCheckedFloat (TIFF *tif, TIFFDirEntry *direntry, float *value)
 Read a prevalidated float value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble (TIFF *tif, TIFFDirEntry *direntry, double *value)
 Read a prevalidated double value.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte (int8_t value)
 Check whether int8_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort (uint16_t value)
 Check whether uint16_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort (int16_t value)
 Check whether int16_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong (uint32_t value)
 Check whether uint32_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong (int32_t value)
 Check whether int32_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8 (uint64_t value)
 Check whether uint64_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8 (int64_t value)
 Check whether int64_t fits uint8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte (uint8_t value)
 Check whether uint8_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort (uint16_t value)
 Check whether uint16_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort (int16_t value)
 Check whether int16_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong (uint32_t value)
 Check whether uint32_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong (int32_t value)
 Check whether int32_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8 (uint64_t value)
 Check whether uint64_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8 (int64_t value)
 Check whether int64_t fits int8_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte (int8_t value)
 Check whether int8_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort (int16_t value)
 Check whether int16_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong (uint32_t value)
 Check whether uint32_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong (int32_t value)
 Check whether int32_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8 (uint64_t value)
 Check whether uint64_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8 (int64_t value)
 Check whether int64_t fits uint16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort (uint16_t value)
 Check whether uint16_t fits int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong (uint32_t value)
 Check whether uint32_t fits int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong (int32_t value)
 Check whether int32_t fits int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8 (uint64_t value)
 Check whether uint64_t fits int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8 (int64_t value)
 Check whether int64_t fits int16_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte (int8_t value)
 Check whether int8_t fits uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort (int16_t value)
 Check whether int16_t fits uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong (int32_t value)
 Check whether int32_t fits uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8 (uint64_t value)
 Check whether uint64_t fits uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8 (int64_t value)
 Check whether int64_t fits uint32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong (uint32_t value)
 Check whether uint32_t fits int32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8 (uint64_t value)
 Check whether uint64_t fits int32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8 (int64_t value)
 Check whether int64_t fits int32_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte (int8_t value)
 Check whether int8_t fits uint64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort (int16_t value)
 Check whether int16_t fits uint64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong (int32_t value)
 Check whether int32_t fits uint64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8 (int64_t value)
 Check whether int64_t fits uint64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8 (uint64_t value)
 Check whether uint64_t fits int64_t.
 
static enum TIFFReadDirEntryErr TIFFReadDirEntryData (TIFF *tif, uint64_t offset, tmsize_t size, void *dest)
 Copy a raw external byte range into caller storage.
 
static void TIFFReadDirEntryOutputErr (TIFF *tif, enum TIFFReadDirEntryErr err, const char *module, const char *tagname, int recover)
 Report a directory-entry conversion error at the requested severity.
 
static int _TIFFGetMaxColorChannels (uint16_t photometric)
 Classify the expected maximum colour-channel count.
 
static int ByteCountLooksBad (TIFF *tif)
 Test whether the first strip byte count needs recovery.
 
static bool EvaluateIFDdatasizeReading (TIFF *tif, TIFFDirEntry *dp)
 Record the external byte range of one IFD entry.
 
static int cmpTIFFEntryOffsetAndLength (const void *a, const void *b)
 Order external IFD ranges by starting byte offset.
 
static void CalcFinalIFDdatasizeReading (TIFF *tif, uint16_t dircount)
 Estimate the reusable contiguous span of the loaded IFD.
 
static void TIFFReadDirectoryCheckOrder (TIFF *tif, TIFFDirEntry *dir, uint16_t dircount)
 Warn if directory tags are not strictly increasing.
 
static TIFFDirEntry * TIFFReadDirectoryFindEntry (TIFF *tif, TIFFDirEntry *dir, uint16_t dircount, uint16_t tagid)
 Find the first parsed entry with a given tag.
 
static void TIFFReadDirectoryFindFieldInfo (TIFF *tif, uint16_t tagid, uint32_t *fii)
 Locate the first registered descriptor index for a tag.
 
static int EstimateStripByteCounts (TIFF *tif, TIFFDirEntry *dir, uint16_t dircount)
 Replace missing or suspect strile byte counts with estimates.
 
static void MissingRequired (TIFF *tif, const char *tagname)
 Report an absent required image tag.
 
static int CheckDirCount (TIFF *tif, TIFFDirEntry *dir, uint32_t count)
 Validate or trim an entry to its expected count.
 
static uint16_t TIFFFetchDirectory (TIFF *tif, uint64_t diroff, TIFFDirEntry **pdir, uint64_t *nextdiroff)
 Fetch and normalise raw classic TIFF or BigTIFF entries.
 
static int TIFFFetchNormalTag (TIFF *tif, TIFFDirEntry *dp, int recover)
 Decode a parsed value according to its registered set/get representation.
 
static int TIFFFetchSubjectDistance (TIFF *tif, TIFFDirEntry *dir)
 Decode EXIF SubjectDistance with its special sentinel values.
 
enum TIFFReadDirEntryErr _TIFFReadDirEntryCheckedRational (TIFF *tif, TIFFDirEntry *direntry, double *value)
 Read a prevalidated rational value.
 

Detailed Description

Fetch, convert, validate, and recover parsed directory entries.

Macro Definition Documentation

◆ FAILED_FII

#define FAILED_FII   ((uint32_t)-1)

Represent a missing field-table index with UINT32_MAX.

Definition at line 54 of file tif_dirread.c.

◆ INITIAL_THRESHOLD

#define INITIAL_THRESHOLD   (1024 * 1024)

Start progressive external-tag reads at one MiB on 64-bit hosts.

Definition at line 1537 of file tif_dirread.c.

◆ MAX_SIZE_TAG_DATA

#define MAX_SIZE_TAG_DATA   2147483647U

Limit source and converted tag arrays to INT32_MAX bytes.

Definition at line 1645 of file tif_dirread.c.

◆ MAX_THRESHOLD

#define MAX_THRESHOLD
Value:
#define INITIAL_THRESHOLD
Start progressive external-tag reads at one MiB on 64-bit hosts.
#define THRESHOLD_MULTIPLIER
Grow progressive read requests by a factor of ten.

Set the progressive read threshold cutoff to 1000 MiB.

Later reads can request the entire remaining value; this is not a maximum request size.

Definition at line 1550 of file tif_dirread.c.

◆ THRESHOLD_MULTIPLIER

#define THRESHOLD_MULTIPLIER   10

Grow progressive read requests by a factor of ten.

Definition at line 1542 of file tif_dirread.c.

◆ TIFFCvtIEEEDoubleToNative

#define TIFFCvtIEEEDoubleToNative (   tif,
  n,
  dp 
)

Recognise already compatible double storage without conversion.

With HAVE_IEEEFP defined this is a no-op macro: arguments are not evaluated and no state, ownership, I/O, diagnostics, or storage changes occur. Non-IEEE ports instead require the external platform hook with this name.

Parameters
[in]tifIgnored handle expression.
[in]nIgnored element-count expression.
[in,out]dpIgnored data-pointer expression; storage is unchanged.

Definition at line 84 of file tif_dirread.c.

◆ TIFFCvtIEEEFloatToNative

#define TIFFCvtIEEEFloatToNative (   tif,
  n,
  fp 
)

Recognise already compatible float storage without conversion.

With HAVE_IEEEFP defined this is a no-op macro: arguments are not evaluated and no state, ownership, I/O, diagnostics, or storage changes occur. Non-IEEE ports instead require the external platform hook with this name.

Parameters
[in]tifIgnored handle expression.
[in]nIgnored element-count expression.
[in,out]fpIgnored data-pointer expression; storage is unchanged.

Definition at line 70 of file tif_dirread.c.

Typedef Documentation

◆ UInt64Aligned_t

Provide aligned scalar and byte views of eight raw bytes.

Used for unaligned-safe copies and rational/component interpretation. Owns no separate storage; file-byte swapping is performed explicitly by each consumer.

Enumeration Type Documentation

◆ TIFFReadDirEntryErr

Classify directory-entry decoding failures.

Ok is zero; nonzero values distinguish malformed counts/types, I/O, range, per-sample inconsistency, size ceilings, and allocation failure. Most low-level converters return these for their caller to diagnose. The code alone does not guarantee unchanged outputs or handle state.

Enumerator
TIFFReadDirEntryErrOk 

Successful or accepted empty conversion.

TIFFReadDirEntryErrCount 

Unsupported or inconsistent element count.

TIFFReadDirEntryErrType 

Unsupported source file data type.

TIFFReadDirEntryErrIo 

Mapped extent, seek, or read failure.

TIFFReadDirEntryErrRange 

Value cannot be represented by the target integer type.

TIFFReadDirEntryErrPsdif 

Per-sample values differ where uniform values are required.

TIFFReadDirEntryErrSizesan 

Source or target array exceeds the configured sanity ceiling.

TIFFReadDirEntryErrAlloc 

Allocation, policy, or large-request/file-size rejection.

Definition at line 3477 of file tiffiop.h.

Function Documentation

◆ _TIFFGetMaxColorChannels()

static int _TIFFGetMaxColorChannels ( uint16_t  photometric)
static

Classify the expected maximum colour-channel count.

Pure photometric classification, not validation of a complete image. No allocation, diagnostics, state, or ownership effects.

Parameters
[in]photometricPHOTOMETRIC_* value.
Returns
One for palette/min-is-white/min-is-black, three for RGB/YCbCr/Lab/LogLuv families, four for separated/mask, zero for unclassified values.

Definition at line 5630 of file tif_dirread.c.

References PHOTOMETRIC_CFA, PHOTOMETRIC_CIELAB, PHOTOMETRIC_ICCLAB, PHOTOMETRIC_ITULAB, PHOTOMETRIC_LOGL, PHOTOMETRIC_LOGLUV, PHOTOMETRIC_MASK, PHOTOMETRIC_MINISBLACK, PHOTOMETRIC_MINISWHITE, PHOTOMETRIC_PALETTE, PHOTOMETRIC_RGB, PHOTOMETRIC_SEPARATED, and PHOTOMETRIC_YCBCR.

Referenced by TIFFReadDirectory().

Here is the caller graph for this function:

◆ _TIFFReadDirEntryCheckedRational()

enum TIFFReadDirEntryErr _TIFFReadDirEntryCheckedRational ( TIFF *  tif,
TIFFDirEntry *  direntry,
double *  value 
)
extern

Read a prevalidated rational value.

Caller must already validate single-element count and type. In BigTIFF copies the eight inline entry bytes; in classic TIFF reads eight bytes from the file at the entry offset (seeking unless memory-mapped). Byte-swaps when TIFF_SWAB is set. Performs no allocation, range validation, diagnostics, or ownership transfer. Divides the unsigned numerator by the denominator in double precision; a zero numerator or denominator gives zero rather than an error. The output is written only on success.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot for the quotient.
Returns
TIFFReadDirEntryErrOk on success, or TIFFReadDirEntryErrIo if the eight bytes at the entry offset cannot be read; the output is valid only on success. No other enumerator is returned.

Definition at line 4426 of file tif_dirread.c.

References _UInt64Aligned_t::i, _UInt64Aligned_t::l, TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrOk, TIFFSwabArrayOfLong(), TIFFSwabLong(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFReadDirEntryDouble(), and TIFFReadDirEntryFloat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ByteCountLooksBad()

static int ByteCountLooksBad ( TIFF *  tif)
static

Test whether the first strip byte count needs recovery.

Used for the reader's single-strip heuristic. Loads offset/count if deferred and may allocate or perform I/O. A zero offset is treated as inconclusive, not bad. Nonzero-offset zero count is bad; uncompressed counts are checked against file remainder and, in read-only mode, full-image row size with overflow detection. Does not repair values or transfer ownership.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
Returns
One for a suspected bad count, zero otherwise; not a full metadata/range validation.

Definition at line 5671 of file tif_dirread.c.

References COMPRESSION_NONE, TIFFDirectory::td_compression, TIFFDirectory::td_imagelength, tiff::tif_dir, tiff::tif_mode, TIFFGetFileSize, TIFFGetStrileByteCount(), TIFFGetStrileOffset(), and TIFFScanlineSize64().

Referenced by TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcFinalIFDdatasizeReading()

static void CalcFinalIFDdatasizeReading ( TIFF *  tif,
uint16_t  dircount 
)
static

Estimate the reusable contiguous span of the loaded IFD.

No-op for read-only mode. Otherwise sorts collected range bookkeeping and counts data contiguous after entry space, allowing selected one-byte padding gaps. May seek to EOF; exact end-of-file adjacency records UINT64_MAX to permit extension. Updates td_dirdatasize_read without allocating or transferring ownership. This is a placement heuristic, not general file-layout validation; seek failure has no separate status.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]dircountFetched number of entries used to compute classic/BigTIFF entry space.

Definition at line 5835 of file tif_dirread.c.

References cmpTIFFEntryOffsetAndLength(), TIFFEntryOffsetAndLength::length, TIFFEntryOffsetAndLength::offset, TIFFDirectory::td_dirdatasize_Noffsets, TIFFDirectory::td_dirdatasize_offsets, TIFFDirectory::td_dirdatasize_read, tiff::tif_dir, tiff::tif_diroff, tiff::tif_flags, tiff::tif_mode, tiff::tif_nextdiroff, TIFF_BIGTIFF, and TIFFSeekFile.

Referenced by TIFFReadCustomDirectory(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckDirCount()

static int CheckDirCount ( TIFF *  tif,
TIFFDirEntry *  dir,
uint32_t  count 
)
static

Validate or trim an entry to its expected count.

A short entry warns and fails without trimming. An excessive count warns, is reduced in the parsed entry, and succeeds. Exact counts succeed silently. Does not fetch data, allocate, or transfer ownership.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in,out]dirNon-NULL parsed entry whose count may be reduced.
[in]countExpected element count.
Returns
One for exact/trimmed counts, zero for insufficient count.

Definition at line 7839 of file tif_dirread.c.

References _TIFFField::field_name, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_tag, tiff::tif_name, TIFFFieldWithTag(), and TIFFWarningExtR().

Referenced by TIFFReadCustomDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmpTIFFEntryOffsetAndLength()

static int cmpTIFFEntryOffsetAndLength ( const void *  a,
const void *  b 
)
static

Order external IFD ranges by starting byte offset.

qsort comparator; borrows two live ranges without allocation, mutation, diagnostics, or ownership transfer. Equal offsets compare equal regardless of lengths.

Parameters
[in]aNon-NULL left TIFFEntryOffsetAndLength pointer.
[in]bNon-NULL right TIFFEntryOffsetAndLength pointer.
Returns
Minus one, zero, or one for ascending offset order.

Definition at line 5799 of file tif_dirread.c.

References TIFFEntryOffsetAndLength::offset.

Referenced by CalcFinalIFDdatasizeReading().

Here is the caller graph for this function:

◆ EstimateStripByteCounts()

static int EstimateStripByteCounts ( TIFF *  tif,
TIFFDirEntry *  dir,
uint16_t  dircount 
)
static

Replace missing or suspect strile byte counts with estimates.

Requires established nonzero strile geometry and valid offset entries. Loads offsets, possibly clears deferred entries, frees the previous count array, and allocates a replacement. Estimates compressed extents from file/IFD space, or uncompressed tile/row sizes, then marks byte-count presence and may default RowsPerStrip. Estimates are heuristics and may be partial on failure. Some overflow failures return silently; allocator/unknown-type/file-size rejection can diagnose. New arrays remain directory-owned; old borrowed views are invalidated.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]dirBorrowed raw entry array used to estimate indirect metadata space.
[in]dircountNumber of parsed entries.
Returns
One after estimates are installed, minus one on detected size, allocation, or offset-load failure; zero is not the failure convention.

Definition at line 7299 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFFillStrilesInternal(), _TIFFfreeExt(), COMPRESSION_NONE, FIELD_ROWSPERSTRIP, FIELD_STRIPBYTECOUNTS, isTiled, PLANARCONFIG_SEPARATE, TIFFDirectory::td_compression, TIFFDirectory::td_imagelength, TIFFDirectory::td_nstrips, TIFFDirectory::td_planarconfig, TIFFDirectory::td_rowsperstrip, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_stripbytecount_p, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_stripsperimage, tiff::tif_dir, tiff::tif_flags, TIFF_BIGTIFF, TIFFDataWidth(), TIFFErrorExtR(), TIFFFieldSet, TIFFGetFileSize, TIFFScanlineSize64(), TIFFSetFieldBit, TIFFTileSize64(), and TIFFWarningExtR().

Referenced by TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EvaluateIFDdatasizeReading()

static bool EvaluateIFDdatasizeReading ( TIFF *  tif,
TIFFDirEntry *  dp 
)
static

Record the external byte range of one IFD entry.

Checks multiplication and accumulation overflow and diagnoses rejection. Caller must supply sufficient td_dirdatasize_offsets capacity. Records only data exceeding inline width; normalises its raw offset and advances range/count bookkeeping. Does not allocate/read the payload or change the input entry. Failure has no general rollback of existing bookkeeping.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]dpNon-NULL parsed borrowed entry.
Returns
True after accounting or no external payload, false on size overflow.

Definition at line 5733 of file tif_dirread.c.

References TIFFEntryOffsetAndLength::length, TIFFEntryOffsetAndLength::offset, TIFFDirectory::td_dirdatasize_Noffsets, TIFFDirectory::td_dirdatasize_offsets, TIFFDirectory::td_dirdatasize_read, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_type, tiff::tif_dir, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFDataWidth(), TIFFErrorExtR(), TIFFSwabLong(), TIFFSwabLong8(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFFetchNormalTag(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MissingRequired()

static void MissingRequired ( TIFF *  tif,
const char *  tagname 
)
static

Report an absent required image tag.

Dispatches an error using a borrowed name. Does not supply a default, alter state, terminate, or transfer ownership.

Parameters
[in]tifNon-NULL handle; used only to dispatch diagnostics.
[in]tagnameNon-NULL null-terminated tag name.

Definition at line 7449 of file tif_dirread.c.

References TIFFErrorExtR().

Referenced by TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFFetchDirectory()

static uint16_t TIFFFetchDirectory ( TIFF *  tif,
uint64_t  diroff,
TIFFDirEntry **  pdir,
uint64_t *  nextdiroff 
)
static

Fetch and normalise raw classic TIFF or BigTIFF entries.

Sets the current offset immediately and optional next-link output to zero before fetching. Rejects counts above 4096, empty directories, invalid extents, and allocation/I/O failures; diagnostics vary by path. Missing/truncated trailing next-link bytes are accepted as zero. Uses mapped storage or client seek/read, allocates temporary raw bytes and final entries, and normalises tag/type/count while leaving offset/inline bytes raw for consumers. Frees temporary storage on detected failure, does not install tag values, and does not roll back handle/next-link state. Only success transfers the final Ext allocation; caller frees it with _TIFFfreeExt(tif,...).

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]diroffIFD offset in file bytes.
[out]pdirNon-NULL empty owner slot; assigned only when entries are successfully fetched.
[out]nextdiroffOptional next-link output; initially zero and may change even if later work fails.
Returns
Fetched positive entry count, or zero for empty/rejected/failed fetch; zero does not preserve handle state.

Definition at line 7895 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), _TIFFmemcpy(), FALSE, isMapped, ReadOK, SeekOK, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_ignore, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_base, tiff::tif_diroff, tiff::tif_flags, tiff::tif_name, tiff::tif_size, TIFF_BIGTIFF, TIFF_SWAB, TIFFErrorExtR(), TIFFGetFileSize, TIFFReadUInt64(), TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), TIFFWarningExtR(), and TIFFDirEntry::toff_long8.

Referenced by TIFFReadCustomDirectory(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFFetchNormalTag()

static int TIFFFetchNormalTag ( TIFF *  tif,
TIFFDirEntry *  dp,
int  recover 
)
static

Decode a parsed value according to its registered set/get representation.

Requires a matching descriptor and representation/count/passcount invariants; OTHER, INT, and C0_ASCII are not generic stored-tag cases. Allocates conversion buffers, can repair/terminate ASCII, then calls TIFFSetField() with representation-specific arguments. Temporary arrays are released after dispatch; setters must copy rather than retain them. Changes values/codec/dirty state without rollback. recover selects warning severity but conversion failure still returns zero; the parent decides whether to ignore it. UNDEFINED representation reports an error and skips the value yet returns one because the local conversion code remains Ok. Diagnostics can come from both converter and setter.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]dpNon-NULL parsed borrowed entry; count/type must match the selected representation.
[in]recoverNonzero for ignored-tag warning severity, zero for error severity; does not change failed conversion to success.
Returns
One after accepted dispatch, or after diagnosed UNDEFINED-representation skip; zero on conversion, schema/count/allocation, or setter failure, even with recover nonzero.

Definition at line 8217 of file tif_dirread.c.

References _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), EvaluateIFDdatasizeReading(), FAILED_FII, _TIFFField::field_name, _TIFFField::field_passcount, _TIFFField::field_readcount, _TIFFField::field_tag, _TIFFField::set_get_field_type, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_fields, tiff::tif_flags, TIFF_LONG, TIFF_SETGET_ASCII, TIFF_SETGET_C0_ASCII, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_C0_IFD8, TIFF_SETGET_C0_SINT16, TIFF_SETGET_C0_SINT32, TIFF_SETGET_C0_SINT64, TIFF_SETGET_C0_SINT8, TIFF_SETGET_C0_UINT16, TIFF_SETGET_C0_UINT32, TIFF_SETGET_C0_UINT64, TIFF_SETGET_C0_UINT8, TIFF_SETGET_C16_ASCII, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_C16_IFD8, TIFF_SETGET_C16_SINT16, TIFF_SETGET_C16_SINT32, TIFF_SETGET_C16_SINT64, TIFF_SETGET_C16_SINT8, TIFF_SETGET_C16_UINT16, TIFF_SETGET_C16_UINT32, TIFF_SETGET_C16_UINT64, TIFF_SETGET_C16_UINT8, TIFF_SETGET_C32_ASCII, TIFF_SETGET_C32_DOUBLE, TIFF_SETGET_C32_FLOAT, TIFF_SETGET_C32_IFD8, TIFF_SETGET_C32_SINT16, TIFF_SETGET_C32_SINT32, TIFF_SETGET_C32_SINT64, TIFF_SETGET_C32_SINT8, TIFF_SETGET_C32_UINT16, TIFF_SETGET_C32_UINT32, TIFF_SETGET_C32_UINT64, TIFF_SETGET_C32_UINT8, TIFF_SETGET_DOUBLE, TIFF_SETGET_FLOAT, TIFF_SETGET_IFD8, TIFF_SETGET_INT, TIFF_SETGET_OTHER, TIFF_SETGET_SINT16, TIFF_SETGET_SINT32, TIFF_SETGET_SINT64, TIFF_SETGET_SINT8, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UINT32, TIFF_SETGET_UINT64, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, TIFF_SWAB, TIFF_VARIABLE, TIFF_VARIABLE2, TIFFErrorExtR(), TIFFReadDirectoryFindFieldInfo(), TIFFReadDirEntryArray(), TIFFReadDirEntryByte(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDouble(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, TIFFReadDirEntryFloat(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntryLong8Array(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryOutputErr(), TIFFReadDirEntrySbyte(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShort(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshort(), TIFFReadDirEntrySshortArray(), TIFFSetField(), TIFFSwabArrayOfLong(), TIFFTAG_RICHTIFFIPTC, and TIFFWarningExtR().

Referenced by TIFFReadCustomDirectory(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFFetchSubjectDistance()

static int TIFFFetchSubjectDistance ( TIFF *  tif,
TIFFDirEntry *  dir 
)
static

Decode EXIF SubjectDistance with its special sentinel values.

Requires the EXIF schema to be active. Checks one RATIONAL, reads raw components, and uses zero for a zero numerator, minus one for UINT32_MAX numerator or zero denominator, otherwise their quotient. Dispatches through TIFFSetField(); no new ownership is exposed. Failed conversion warns and returns zero; setter effects/diagnostics and partial failure rules still apply. Classic TIFF access can change I/O position.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]dirNon-NULL parsed SubjectDistance entry.
Returns
TIFFSetField() result on decoded input, zero on count/type/I/O error; the custom top-level reader ignores this result.

Definition at line 9742 of file tif_dirread.c.

References _UInt64Aligned_t::i, _UInt64Aligned_t::l, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BIGTIFF, TIFF_RATIONAL, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFReadDirEntryOutputErr(), TIFFSetField(), TIFFSwabArrayOfLong(), TIFFSwabLong(), TIFFDirEntry::toff_long8, and TRUE.

Referenced by TIFFReadCustomDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirectoryCheckOrder()

static void TIFFReadDirectoryCheckOrder ( TIFF *  tif,
TIFFDirEntry *  dir,
uint16_t  dircount 
)
static

Warn if directory tags are not strictly increasing.

Checks a borrowed array in place without sorting or marking duplicates. Emits at most one order warning; equal adjacent tags also trigger it. No allocation or ownership transfer.

Parameters
[in]tifNon-NULL handle; used only to dispatch diagnostics.
[in]dirReadable borrowed array of dircount parsed entries.
[in]dircountNumber of entries.

Definition at line 6898 of file tif_dirread.c.

References TIFFDirEntry::tdir_tag, and TIFFWarningExtR().

Referenced by TIFFReadCustomDirectory(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirectoryFindEntry()

static TIFFDirEntry * TIFFReadDirectoryFindEntry ( TIFF *  tif,
TIFFDirEntry *  dir,
uint16_t  dircount,
uint16_t  tagid 
)
static

Find the first parsed entry with a given tag.

Linear search without allocation, mutation, I/O, or diagnostics. The tif argument is unused. Does not filter tdir_ignore or verify type/count.

Parameters
[in]tifUnused.
[in]dirReadable borrowed entry array.
[in]dircountNumber of entries.
[in]tagidOn-disk tag number.
Returns
Borrowed entry pointer into dir, or NULL if absent; lifetime follows dir.

Definition at line 6933 of file tif_dirread.c.

References TIFFDirEntry::tdir_tag.

Referenced by TIFFReadDirectory().

Here is the caller graph for this function:

◆ TIFFReadDirectoryFindFieldInfo()

static void TIFFReadDirectoryFindFieldInfo ( TIFF *  tif,
uint16_t  tagid,
uint32_t *  fii 
)
static

Locate the first registered descriptor index for a tag.

Binary-searches a valid tag-sorted handle table, then backs up over equal tag numbers. Does not validate the file type, allocate, issue diagnostics, or transfer ownership. Caller must keep the table stable during the search.

Parameters
[in]tifNon-NULL handle whose tif_fields table is searched; not modified.
[in]tagidOn-disk tag number.
[out]fiiNon-NULL slot for the first descriptor index or FAILED_FII.

Definition at line 6963 of file tif_dirread.c.

References FAILED_FII, _TIFFField::field_tag, tiff::tif_fields, and tiff::tif_nfields.

Referenced by TIFFFetchNormalTag(), TIFFReadCustomDirectory(), and TIFFReadDirectory().

Here is the caller graph for this function:

◆ TIFFReadDirEntryArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint32_t *  count,
uint32_t  desttypesize,
void **  value 
)
static

Fetch raw directory array bytes with checked size limits.

Copies bytes without element swapping/conversion, preserving the original entry. Applies the MAX_SIZE_TAG_DATA ceiling to source and destination element products and large-request/file-size checks. Uses inline bytes or external I/O; may allocate progressively. Empty/unknown-width data succeeds with *value NULL without setting count. Successful nonempty storage belongs to the caller and must be freed with _TIFFfreeExt(tif,...); supply no prior owned allocation. Temporary data is freed on detected read failure. Delegates to the limited variant with UINT64_MAX maximum. May seek and read when not memory-mapped. The oversized-request check warns and allocation failures are diagnosed; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]countNon-NULL element-count slot; assigned before some later failures, and not assigned on the zero/unknown-width success path.
[in]desttypesizePositive intended output element width used for the size ceiling, not conversion.
[out]valueNon-NULL empty owner slot; success supplies a new matching Ext allocation or NULL; errors do not uniformly initialise it.
Returns
TIFFReadDirEntryErrOk for fetched or empty/unknown-width data, otherwise a size/allocation/I/O code; output count is valid only for nonempty success.

Definition at line 1835 of file tif_dirread.c.

References TIFFReadDirEntryArrayWithLimit().

Referenced by TIFFFetchNormalTag(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLongArray(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), and TIFFReadDirEntrySshortArray().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryArrayWithLimit()

static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint32_t *  count,
uint32_t  desttypesize,
void **  value,
uint64_t  maxcount 
)
static

Fetch raw directory array bytes with checked size limits.

Copies bytes without element swapping/conversion, preserving the original entry. Applies the MAX_SIZE_TAG_DATA ceiling to source and destination element products and large-request/file-size checks. Uses inline bytes or external I/O; may allocate progressively. Empty/unknown-width data succeeds with *value NULL without setting count. Successful nonempty storage belongs to the caller and must be freed with _TIFFfreeExt(tif,...); supply no prior owned allocation. Temporary data is freed on detected read failure. May seek and read when not memory-mapped. The oversized-request check warns and allocation failures are diagnosed; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]countNon-NULL element-count slot; assigned before some later failures, and not assigned on the zero/unknown-width success path.
[in]desttypesizePositive intended output element width used for the size ceiling, not conversion.
[out]valueNon-NULL empty owner slot; success supplies a new matching Ext allocation or NULL; errors do not uniformly initialise it.
[in]maxcountMaximum elements to fetch; original count still determines inline/external placement.
Returns
TIFFReadDirEntryErrOk for fetched or empty/unknown-width data, otherwise a size/allocation/I/O code; output count is valid only for nonempty success.

Definition at line 1678 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), _TIFFmemcpy(), isMapped, MAX_SIZE_TAG_DATA, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_flags, tiff::tif_size, TIFF_BIGTIFF, TIFF_SWAB, TIFFDataWidth(), TIFFGetFileSize, TIFFReadDirEntryData(), TIFFReadDirEntryDataAndRealloc(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrIo, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrSizesan, TIFFSwabLong(), TIFFSwabLong8(), TIFFWarningExtR(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFReadDirEntryArray(), and TIFFReadDirEntryLong8ArrayWithLimit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryByte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryByte ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint8_t *  value 
)
static

Convert one directory value to uint8_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_UNDEFINED, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_BYTE and TIFF_UNDEFINED are copied; every other type is rejected with TIFFReadDirEntryErrRange unless the value is in 0..UINT8_MAX. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 394 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_UNDEFINED, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeByteLong(), TIFFReadDirEntryCheckRangeByteLong8(), TIFFReadDirEntryCheckRangeByteSbyte(), TIFFReadDirEntryCheckRangeByteShort(), TIFFReadDirEntryCheckRangeByteSlong(), TIFFReadDirEntryCheckRangeByteSlong8(), TIFFReadDirEntryCheckRangeByteSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryByteArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint8_t **  value 
)
static

Read a directory array as uint8_t elements.

Accepts TIFF_ASCII, TIFF_UNDEFINED, TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_ASCII, TIFF_UNDEFINED and TIFF_BYTE are returned as fetched; TIFF_SBYTE is range-checked in place. Wider types are converted into a new array. Any element outside 0..UINT8_MAX fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 1870 of file tif_dirread.c.

References _TIFFfreeExt(), _TIFFmallocExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_ASCII, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFF_UNDEFINED, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeByteLong(), TIFFReadDirEntryCheckRangeByteLong8(), TIFFReadDirEntryCheckRangeByteSbyte(), TIFFReadDirEntryCheckRangeByteShort(), TIFFReadDirEntryCheckRangeByteSlong(), TIFFReadDirEntryCheckRangeByteSlong8(), TIFFReadDirEntryCheckRangeByteSshort(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedByte()

static void TIFFReadDirEntryCheckedByte ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint8_t *  value 
)
static

Read a prevalidated uint8_t value.

Caller must already validate single-element count/type and inline storage. Copies the first inline entry byte; no byte swapping applies. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifUnused.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4219 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset.

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedDouble()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble ( TIFF *  tif,
TIFFDirEntry *  direntry,
double *  value 
)
static

Read a prevalidated double value.

Caller must already validate single-element count and type. In BigTIFF copies the eight inline entry bytes; in classic TIFF reads eight bytes from the file at the entry offset with TIFFReadDirEntryData() (seeking unless memory-mapped). Byte-swaps when TIFF_SWAB is set. Performs no allocation, range validation, diagnostics, or ownership transfer. A classic TIFF read failure can leave the output partially written; use it only on success.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.
Returns
TIFFReadDirEntryErrOk on success, otherwise an I/O error; use output only on success.

Definition at line 4629 of file tif_dirread.c.

References _UInt64Aligned_t::d, _UInt64Aligned_t::l, TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrOk, TIFFSwabLong(), TIFFSwabLong8(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFReadDirEntryDouble(), and TIFFReadDirEntryFloat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedFloat()

static void TIFFReadDirEntryCheckedFloat ( TIFF *  tif,
TIFFDirEntry *  direntry,
float *  value 
)
static

Read a prevalidated float value.

Caller must already validate single-element count/type and inline storage. Copies the leading inline entry bytes and byte-swaps the result when TIFF_SWAB is set. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifNon-NULL handle; only TIFF_SWAB in tif_flags is read.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4591 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_SWAB, and TIFFSwabLong().

Referenced by TIFFReadDirEntryDouble(), and TIFFReadDirEntryFloat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedLong()

static void TIFFReadDirEntryCheckedLong ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint32_t *  value 
)
static

Read a prevalidated uint32_t value.

Caller must already validate single-element count/type and inline storage. Copies the leading inline entry bytes and byte-swaps the result when TIFF_SWAB is set. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifNon-NULL handle; only TIFF_SWAB in tif_flags is read.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4313 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_SWAB, and TIFFSwabLong().

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryIfd8(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8 ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t *  value 
)
static

Read a prevalidated uint64_t value.

Caller must already validate single-element count and type. In BigTIFF copies the eight inline entry bytes; in classic TIFF reads eight bytes from the file at the entry offset with TIFFReadDirEntryData() (seeking unless memory-mapped). Byte-swaps when TIFF_SWAB is set. Performs no allocation, range validation, diagnostics, or ownership transfer. A classic TIFF read failure can leave the output partially written; use it only on success.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.
Returns
TIFFReadDirEntryErrOk on success, otherwise an I/O error; use output only on success.

Definition at line 4366 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrOk, TIFFSwabLong(), TIFFSwabLong8(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryIfd8(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedSbyte()

static void TIFFReadDirEntryCheckedSbyte ( TIFF *  tif,
TIFFDirEntry *  direntry,
int8_t *  value 
)
static

Read a prevalidated int8_t value.

Caller must already validate single-element count/type and inline storage. Copies the first inline entry byte; no byte swapping applies. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifUnused.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4241 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset.

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedShort()

static void TIFFReadDirEntryCheckedShort ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint16_t *  value 
)
static

Read a prevalidated uint16_t value.

Caller must already validate single-element count/type and inline storage. Copies the leading inline entry bytes and byte-swaps the result when TIFF_SWAB is set. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifNon-NULL handle; only TIFF_SWAB in tif_flags is read.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4264 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_SWAB, TIFFSwabShort(), and TIFFDirEntry::toff_short.

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedSlong()

static void TIFFReadDirEntryCheckedSlong ( TIFF *  tif,
TIFFDirEntry *  direntry,
int32_t *  value 
)
static

Read a prevalidated int32_t value.

Caller must already validate single-element count/type and inline storage. Copies the leading inline entry bytes and byte-swaps the result when TIFF_SWAB is set. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifNon-NULL handle; only TIFF_SWAB in tif_flags is read.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4337 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_SWAB, and TIFFSwabLong().

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8 ( TIFF *  tif,
TIFFDirEntry *  direntry,
int64_t *  value 
)
static

Read a prevalidated int64_t value.

Caller must already validate single-element count and type. In BigTIFF copies the eight inline entry bytes; in classic TIFF reads eight bytes from the file at the entry offset with TIFFReadDirEntryData() (seeking unless memory-mapped). Byte-swaps when TIFF_SWAB is set. Performs no allocation, range validation, diagnostics, or ownership transfer. A classic TIFF read failure can leave the output partially written; use it only on success.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.
Returns
TIFFReadDirEntryErrOk on success, otherwise an I/O error; use output only on success.

Definition at line 4406 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrOk, TIFFSwabLong(), TIFFSwabLong8(), and TIFFDirEntry::toff_long.

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedSrational()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational ( TIFF *  tif,
TIFFDirEntry *  direntry,
double *  value 
)
static

Read a prevalidated srational value.

Caller must already validate single-element count and type. In BigTIFF copies the eight inline entry bytes; in classic TIFF reads eight bytes from the file at the entry offset with TIFFReadDirEntryData() (seeking unless memory-mapped). Byte-swaps when TIFF_SWAB is set. Performs no allocation, range validation, diagnostics, or ownership transfer. Divides the signed 32-bit numerator by the unsigned denominator in double precision; a zero numerator or denominator gives zero. The output is written only on success.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.
Returns
TIFFReadDirEntryErrOk on success, otherwise an I/O error; use output only on success.

Definition at line 4480 of file tif_dirread.c.

References _UInt64Aligned_t::i, _UInt64Aligned_t::l, TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFReadDirEntryData(), TIFFReadDirEntryErrOk, TIFFSwabArrayOfLong(), TIFFSwabLong(), TIFFDirEntry::toff_long, and TIFFDirEntry::toff_long8.

Referenced by TIFFReadDirEntryDouble(), and TIFFReadDirEntryFloat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckedSshort()

static void TIFFReadDirEntryCheckedSshort ( TIFF *  tif,
TIFFDirEntry *  direntry,
int16_t *  value 
)
static

Read a prevalidated int16_t value.

Caller must already validate single-element count/type and inline storage. Copies the leading inline entry bytes and byte-swaps the result when TIFF_SWAB is set. Performs no allocation, I/O, diagnostics, range validation, or ownership transfer. The Checked name denotes caller-established preconditions.

Parameters
[in]tifNon-NULL handle; only TIFF_SWAB in tif_flags is read.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned output slot of the matching representation.

Definition at line 4289 of file tif_dirread.c.

References TIFFDirEntry::tdir_offset, tiff::tif_flags, TIFF_SWAB, and TIFFSwabShort().

Referenced by TIFFReadDirEntryByte(), TIFFReadDirEntryDouble(), TIFFReadDirEntryFloat(), TIFFReadDirEntryLong(), TIFFReadDirEntryLong8(), TIFFReadDirEntrySbyte(), TIFFReadDirEntryShort(), TIFFReadDirEntrySlong(), TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong ( uint32_t  value)
static

Check whether uint32_t fits uint8_t.

Rejects when value > 0xFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4731 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8 ( uint64_t  value)
static

Check whether uint64_t fits uint8_t.

Rejects when value > 0xFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4773 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteSbyte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte ( int8_t  value)
static

Check whether int8_t fits uint8_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4668 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteShort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort ( uint16_t  value)
static

Check whether uint16_t fits uint8_t.

Rejects when value > 0xFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4689 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteSlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong ( int32_t  value)
static

Check whether int32_t fits uint8_t.

Rejects when (value < 0) || (value > 0xFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4752 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8 ( int64_t  value)
static

Check whether int64_t fits uint8_t.

Rejects when (value < 0) || (value > 0xFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4794 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeByteSshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort ( int16_t  value)
static

Check whether int16_t fits uint8_t.

Rejects when (value < 0) || (value > 0xFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4710 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryByte(), and TIFFReadDirEntryByteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLong8Sbyte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte ( int8_t  value)
static

Check whether int8_t fits uint64_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5364 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong8(), and TIFFReadDirEntryLong8ArrayWithLimit().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLong8Slong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong ( int32_t  value)
static

Check whether int32_t fits uint64_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5406 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong8(), and TIFFReadDirEntryLong8ArrayWithLimit().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLong8Slong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8 ( int64_t  value)
static

Check whether int64_t fits uint64_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5427 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong8(), and TIFFReadDirEntryLong8ArrayWithLimit().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLong8Sshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort ( int16_t  value)
static

Check whether int16_t fits uint64_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5385 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong8(), and TIFFReadDirEntryLong8ArrayWithLimit().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLongLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8 ( uint64_t  value)
static

Check whether uint64_t fits uint32_t.

Rejects when value > UINT32_MAX. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5256 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong(), and TIFFReadDirEntryLongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLongSbyte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte ( int8_t  value)
static

Check whether int8_t fits uint32_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5193 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong(), and TIFFReadDirEntryLongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLongSlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong ( int32_t  value)
static

Check whether int32_t fits uint32_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5235 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong(), and TIFFReadDirEntryLongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLongSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8 ( int64_t  value)
static

Check whether int64_t fits uint32_t.

Rejects when (value < 0) || (value > (int64_t)UINT32_MAX). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5277 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong(), and TIFFReadDirEntryLongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeLongSshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort ( int16_t  value)
static

Check whether int16_t fits uint32_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5214 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryLong(), and TIFFReadDirEntryLongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteByte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte ( uint8_t  value)
static

Check whether uint8_t fits int8_t.

Rejects when value > 0x7F. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4815 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong ( uint32_t  value)
static

Check whether uint32_t fits int8_t.

Rejects when value > 0x7F. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4878 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8 ( uint64_t  value)
static

Check whether uint64_t fits int8_t.

Rejects when value > 0x7F. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4920 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteShort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort ( uint16_t  value)
static

Check whether uint16_t fits int8_t.

Rejects when value > 0x7F. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4836 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteSlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong ( int32_t  value)
static

Check whether int32_t fits int8_t.

Rejects when (value < -0x80) || (value > 0x7F). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4899 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8 ( int64_t  value)
static

Check whether int64_t fits int8_t.

Rejects when (value < -0x80) || (value > 0x7F). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4941 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSbyteSshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort ( int16_t  value)
static

Check whether int16_t fits int8_t.

Rejects when (value < -0x80) || (value > 0x7F). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4857 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySbyte(), and TIFFReadDirEntrySbyteArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong ( uint32_t  value)
static

Check whether uint32_t fits uint16_t.

Rejects when value > 0xFFFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5004 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8 ( uint64_t  value)
static

Check whether uint64_t fits uint16_t.

Rejects when value > 0xFFFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5046 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortSbyte()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte ( int8_t  value)
static

Check whether int8_t fits uint16_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4962 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortSlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong ( int32_t  value)
static

Check whether int32_t fits uint16_t.

Rejects when (value < 0) || (value > 0xFFFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5025 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8 ( int64_t  value)
static

Check whether int64_t fits uint16_t.

Rejects when (value < 0) || (value > 0xFFFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5067 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeShortSshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort ( int16_t  value)
static

Check whether int16_t fits uint16_t.

Rejects when value < 0. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 4983 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntryShort(), and TIFFReadDirEntryShortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSlong8Long8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8 ( uint64_t  value)
static

Check whether uint64_t fits int64_t.

Rejects when value > INT64_MAX. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5448 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySlong8(), and TIFFReadDirEntrySlong8Array().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSlongLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong ( uint32_t  value)
static

Check whether uint32_t fits int32_t.

Rejects when value > 0x7FFFFFFFUL. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5298 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySlong(), and TIFFReadDirEntrySlongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSlongLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8 ( uint64_t  value)
static

Check whether uint64_t fits int32_t.

Rejects when value > 0x7FFFFFFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5320 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySlong(), and TIFFReadDirEntrySlongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSlongSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8 ( int64_t  value)
static

Check whether int64_t fits int32_t.

Rejects when (value < 0 - ((int64_t)0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5343 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySlong(), and TIFFReadDirEntrySlongArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSshortLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong ( uint32_t  value)
static

Check whether uint32_t fits int16_t.

Rejects when value > 0x7FFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5109 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySshort(), and TIFFReadDirEntrySshortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSshortLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8 ( uint64_t  value)
static

Check whether uint64_t fits int16_t.

Rejects when value > 0x7FFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5151 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySshort(), and TIFFReadDirEntrySshortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSshortShort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort ( uint16_t  value)
static

Check whether uint16_t fits int16_t.

Rejects when value > 0x7FFF. Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5088 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySshort(), and TIFFReadDirEntrySshortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSshortSlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong ( int32_t  value)
static

Check whether int32_t fits int16_t.

Rejects when (value < -0x8000) || (value > 0x7FFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5130 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySshort(), and TIFFReadDirEntrySshortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryCheckRangeSshortSlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8 ( int64_t  value)
static

Check whether int64_t fits int16_t.

Rejects when (value < -0x8000) || (value > 0x7FFF). Performs no cast, allocation, diagnostic, state change, or ownership transfer.

Parameters
[in]valueSource scalar whose representable target range is checked.
Returns
TIFFReadDirEntryErrRange on rejection, TIFFReadDirEntryErrOk otherwise.

Definition at line 5172 of file tif_dirread.c.

References TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrRange.

Referenced by TIFFReadDirEntrySshort(), and TIFFReadDirEntrySshortArray().

Here is the caller graph for this function:

◆ TIFFReadDirEntryData()

static enum TIFFReadDirEntryErr TIFFReadDirEntryData ( TIFF *  tif,
uint64_t  offset,
tmsize_t  size,
void *  dest 
)
static

Copy a raw external byte range into caller storage.

Requires adequate non-overlapping destination. Rejects a non-positive size before accessing the destination or performing I/O. Copies mapped bytes after extent checks, or seeks/reads client I/O. Does not swap/convert, allocate, transfer ownership, or issue a direct diagnostic. A short read can partially overwrite the output and move I/O position.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]offsetByte offset of source data.
[in]sizeRequested byte count; non-positive values are rejected.
[out]destWritable caller-owned buffer of size bytes for positive size.
Returns
TIFFReadDirEntryErrOk on complete copy, ErrSizesan for a non-positive size, ErrIo on range/seek/read failure; no rollback.

Definition at line 5474 of file tif_dirread.c.

References _TIFFmemcpy(), isMapped, ReadOK, SeekOK, tiff::tif_base, tiff::tif_size, TIFFReadDirEntryErrIo, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrSizesan.

Referenced by _TIFFReadDirEntryCheckedRational(), TIFFFetchSubjectDistance(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryCheckedDouble(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSlong8(), and TIFFReadDirEntryCheckedSrational().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryDataAndRealloc()

static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc ( TIFF *  tif,
uint64_t  offset,
tmsize_t  size,
void **  pdest 
)
static

Grow an owned buffer while reading an external value.

Requires non-mapped I/O and a NULL or matching Ext allocation slot. Seeks to offset, then reallocates and reads progressively (1 MiB, factor ten growth on 64-bit hosts); 32-bit hosts request the full size. Updates *pdest after each successful realloc. On allocation/read failure retains the latest allocation and partial contents for the caller to release with _TIFFfreeExt(); old addresses can already be invalidated. Does not restore file position. Rejects a non-positive size before seeking or reallocating. Allocation failure is diagnosed; seek/read errors return codes without a direct helper diagnostic.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]offsetStart offset in file bytes.
[in]sizeRequested byte count; non-positive values are rejected.
[in,out]pdestNon-NULL owner slot; caller retains responsibility for the latest pointer on all exits.
Returns
TIFFReadDirEntryErrOk when all bytes read, ErrSizesan for a non-positive size, ErrAlloc or ErrIo otherwise; no rollback.

Definition at line 1577 of file tif_dirread.c.

References _TIFFreallocExt(), INITIAL_THRESHOLD, isMapped, MAX_THRESHOLD, SeekOK, THRESHOLD_MULTIPLIER, tiff::tif_name, TIFF_SSIZE_FORMAT, TIFFErrorExtR(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrIo, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrSizesan, and TIFFReadFile.

Referenced by TIFFReadDirEntryArrayWithLimit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryDouble()

static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble ( TIFF *  tif,
TIFFDirEntry *  direntry,
double *  value 
)
static

Convert one directory value to double.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE. TIFF_DOUBLE is copied and TIFF_FLOAT and the 8- to 32-bit integer types convert exactly; TIFF_LONG8/TIFF_SLONG8 magnitudes above 2^53 may lose precision. Rationals are divided in double precision; a zero denominator gives zero, and SRATIONAL uses a signed numerator over an unsigned denominator. No range errors are returned. TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL and TIFF_DOUBLE values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/I/O error; no owned output.

Definition at line 1397 of file tif_dirread.c.

References _TIFFReadDirEntryCheckedRational(), TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_LONG, TIFF_LONG8, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedDouble(), TIFFReadDirEntryCheckedFloat(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSrational(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryDoubleArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
double **  value 
)
static

Read a directory array as double elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_DOUBLE is returned as fetched. Other types are converted into a new array with C casts; only TIFF_LONG8/TIFF_SLONG8 magnitudes above 2^53 can lose precision. Rationals are divided in double precision; a zero denominator gives zero, and SRATIONAL uses a signed numerator over an unsigned denominator. No range errors are returned. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type and allocation errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, size, allocation, or I/O error; only success transfers ownership.

Definition at line 3796 of file tif_dirread.c.

References _TIFFfreeExt(), _TIFFmallocExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_LONG, TIFF_LONG8, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_SWAB, TIFFCvtIEEEDoubleToNative, TIFFCvtIEEEFloatToNative, TIFFReadDirEntryArray(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong(), TIFFSwabArrayOfLong8(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryFloat()

static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat ( TIFF *  tif,
TIFFDirEntry *  direntry,
float *  value 
)
static

Convert one directory value to float.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE. TIFF_FLOAT is copied. Integer sources are converted with a C cast and may lose precision. Rationals are divided in double precision and then cast; a zero denominator gives zero, and SRATIONAL uses a signed numerator over an unsigned denominator. A TIFF_DOUBLE outside +/-FLT_MAX returns TIFFReadDirEntryErrRange; NaN and in-range values are cast. TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL and TIFF_DOUBLE values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 1264 of file tif_dirread.c.

References _TIFFReadDirEntryCheckedRational(), TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_LONG, TIFF_LONG8, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedDouble(), TIFFReadDirEntryCheckedFloat(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSrational(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrRange, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryFloatArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
float **  value 
)
static

Read a directory array as float elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_RATIONAL, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_FLOAT is returned as fetched. Other types are converted into a new array with C casts, which may lose precision. Rationals are divided in float precision; a zero denominator gives zero, and SRATIONAL uses a signed numerator over an unsigned denominator. No range errors are returned. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type and allocation errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, size, allocation, or I/O error; only success transfers ownership.
Note
DOUBLE array input is clamped to +/-FLT_MAX before conversion (NaN passes through). The scalar float reader TIFFReadDirEntryFloat() instead rejects out-of-range DOUBLE values with TIFFReadDirEntryErrRange.

Definition at line 3525 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_LONG, TIFF_LONG8, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_SWAB, TIFFCvtIEEEDoubleToNative, TIFFCvtIEEEFloatToNative, TIFFReadDirEntryArray(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong(), TIFFSwabArrayOfLong8(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryIfd8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8 ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t *  value 
)
static

Convert one directory value to uint64_t directory offset.

Requires count exactly one. Accepts TIFF_LONG, TIFF_IFD, TIFF_LONG8, TIFF_IFD8. TIFF_LONG/TIFF_IFD values are widened and TIFF_LONG8/TIFF_IFD8 are copied; no range checks apply. TIFF_LONG8 and TIFF_IFD8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/I/O error; no owned output.

Definition at line 1509 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryIfd8Array()

static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t **  value 
)
static

Read a directory array as uint64_t directory offset elements.

Accepts TIFF_LONG, TIFF_LONG8, TIFF_IFD, TIFF_IFD8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_LONG8 and TIFF_IFD8 are returned as fetched; TIFF_LONG and TIFF_IFD are widened into a new array. No range checks apply. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type and allocation errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, size, allocation, or I/O error; only success transfers ownership.

Definition at line 4055 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong8(), and TIFFSwabLong().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryLong()

static enum TIFFReadDirEntryErr TIFFReadDirEntryLong ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint32_t *  value 
)
static

Convert one directory value to uint32_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_IFD, TIFF_SLONG, TIFF_LONG8, TIFF_IFD8, TIFF_SLONG8. TIFF_LONG/TIFF_IFD are copied and TIFF_BYTE/TIFF_SHORT widened; the other types are rejected with TIFFReadDirEntryErrRange unless the value is in 0..UINT32_MAX. TIFF_LONG8, TIFF_IFD8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 848 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeLongLong8(), TIFFReadDirEntryCheckRangeLongSbyte(), TIFFReadDirEntryCheckRangeLongSlong(), TIFFReadDirEntryCheckRangeLongSlong8(), TIFFReadDirEntryCheckRangeLongSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryLong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8 ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t *  value 
)
static

Convert one directory value to uint64_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_IFD, TIFF_SLONG, TIFF_LONG8, TIFF_IFD8, TIFF_SLONG8. TIFF_LONG8/TIFF_IFD8 are copied and the unsigned types widened; negative TIFF_SBYTE, TIFF_SSHORT, TIFF_SLONG and TIFF_SLONG8 values are rejected with TIFFReadDirEntryErrRange. TIFF_LONG8, TIFF_IFD8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 1061 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeLong8Sbyte(), TIFFReadDirEntryCheckRangeLong8Slong(), TIFFReadDirEntryCheckRangeLong8Slong8(), TIFFReadDirEntryCheckRangeLong8Sshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryLong8Array()

static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t **  value 
)
static

Read a directory array as uint64_t elements.

Calls TIFFReadDirEntryLong8ArrayWithLimit() with no element limit; see that function for the accepted types, conversions, range errors and error-path state of *value. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 3303 of file tif_dirread.c.

References TIFFReadDirEntryLong8ArrayWithLimit().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryLong8ArrayWithLimit()

static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint64_t **  value,
uint64_t  maxcount 
)
static

Read a directory array as uint64_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_IFD, TIFF_IFD8. Reads at most maxcount elements. Fetches the raw elements with TIFFReadDirEntryArrayWithLimit() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_LONG8 and TIFF_IFD8 are returned as fetched; TIFF_SLONG8 is range-checked in place. Other types are converted into a new array: the unsigned types are widened, and a negative signed element fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
[in]maxcountMaximum elements to read/convert; preserves inline-versus-external placement from the original count.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 3106 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryCheckRangeLong8Sbyte(), TIFFReadDirEntryCheckRangeLong8Slong(), TIFFReadDirEntryCheckRangeLong8Slong8(), TIFFReadDirEntryCheckRangeLong8Sshort(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong8(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchStripThing(), and TIFFReadDirEntryLong8Array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryLongArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint32_t **  value 
)
static

Read a directory array as uint32_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8, TIFF_IFD, TIFF_IFD8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_LONG and TIFF_IFD are returned as fetched; TIFF_SLONG is range-checked in place. Other types are converted into a new array: TIFF_BYTE and TIFF_SHORT are widened, and any other element outside 0..UINT32_MAX fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 2701 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeLongLong8(), TIFFReadDirEntryCheckRangeLongSbyte(), TIFFReadDirEntryCheckRangeLongSlong(), TIFFReadDirEntryCheckRangeLongSlong8(), TIFFReadDirEntryCheckRangeLongSshort(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryOutputErr()

static void TIFFReadDirEntryOutputErr ( TIFF *  tif,
enum TIFFReadDirEntryErr  err,
const char *  module,
const char *  tagname,
int  recover 
)
static

Report a directory-entry conversion error at the requested severity.

Dispatches a synchronous per-handle/global diagnostic using borrowed context strings. recover changes error to warning and appends the ignored-tag message; it does not itself ignore, undo, or free a value. Passing Ok or an unknown code is a programmer error asserted in debug builds. No ownership transfers.

Parameters
[in]tifNon-NULL handle; used only to dispatch diagnostics.
[in]errKnown non-Ok TIFFReadDirEntryErr value.
[in]moduleBorrowed diagnostic context string, or NULL as permitted by diagnostics.
[in]tagnameNon-NULL readable terminated tag name.
[in]recoverNonzero for a recoverable warning, zero for an error.

Definition at line 5519 of file tif_dirread.c.

References TIFFErrorExtR(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrCount, TIFFReadDirEntryErrIo, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrPsdif, TIFFReadDirEntryErrRange, TIFFReadDirEntryErrSizesan, TIFFReadDirEntryErrType, and TIFFWarningExtR().

Referenced by TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFetchSubjectDistance(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryPersampleShort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint16_t *  value 
)
static

Reduce equal per-sample short values to one scalar.

Requires positive SamplesPerPixel. Converts an allocated short array, compares the expected present values, and frees it. Zero count fails; short nonzero count warns and assumes missing values equal the first; extra count warns and is ignored after conversion. Writes the first value before discovering later differences, so failure need not preserve output. May read external data and change client I/O position; allocations/limits or callbacks can emit diagnostics, but conversion failures normally return an error code for the caller to report. No input ownership transfers. Use outputs only on the documented success path; failure does not generally preserve them.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL scalar slot; valid only after successful nonempty conversion/equality check.
Returns
TIFFReadDirEntryErrOk on accepted uniform values, ErrPsdif for differing samples, or a count/conversion/load error.

Definition at line 4146 of file tif_dirread.c.

References _TIFFfreeExt(), _TIFFField::field_name, TIFFDirectory::td_samplesperpixel, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_tag, tiff::tif_dir, TIFFFieldWithTag(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrPsdif, TIFFReadDirEntryShortArray(), and TIFFWarningExtR().

Referenced by TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySbyte()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyte ( TIFF *  tif,
TIFFDirEntry *  direntry,
int8_t *  value 
)
static

Convert one directory value to int8_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_UNDEFINED, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_SBYTE is copied; every other type is rejected with TIFFReadDirEntryErrRange unless the value is in INT8_MIN..INT8_MAX. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 510 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_UNDEFINED, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeSbyteByte(), TIFFReadDirEntryCheckRangeSbyteLong(), TIFFReadDirEntryCheckRangeSbyteLong8(), TIFFReadDirEntryCheckRangeSbyteShort(), TIFFReadDirEntryCheckRangeSbyteSlong(), TIFFReadDirEntryCheckRangeSbyteSlong8(), TIFFReadDirEntryCheckRangeSbyteSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySbyteArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
int8_t **  value 
)
static

Read a directory array as int8_t elements.

Accepts TIFF_UNDEFINED, TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_SBYTE is returned as fetched; TIFF_UNDEFINED and TIFF_BYTE are range-checked in place. Wider types are converted into a new array. Any element outside INT8_MIN..INT8_MAX fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 2083 of file tif_dirread.c.

References _TIFFfreeExt(), _TIFFmallocExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFF_UNDEFINED, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeSbyteByte(), TIFFReadDirEntryCheckRangeSbyteLong(), TIFFReadDirEntryCheckRangeSbyteLong8(), TIFFReadDirEntryCheckRangeSbyteShort(), TIFFReadDirEntryCheckRangeSbyteSlong(), TIFFReadDirEntryCheckRangeSbyteSlong8(), TIFFReadDirEntryCheckRangeSbyteSshort(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryShort()

static enum TIFFReadDirEntryErr TIFFReadDirEntryShort ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint16_t *  value 
)
static

Convert one directory value to uint16_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_SHORT is copied and TIFF_BYTE widened; the other types are rejected with TIFFReadDirEntryErrRange unless the value is in 0..UINT16_MAX. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 628 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeShortLong(), TIFFReadDirEntryCheckRangeShortLong8(), TIFFReadDirEntryCheckRangeShortSbyte(), TIFFReadDirEntryCheckRangeShortSlong(), TIFFReadDirEntryCheckRangeShortSlong8(), TIFFReadDirEntryCheckRangeShortSshort(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag(), and TIFFReadDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntryShortArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
uint16_t **  value 
)
static

Read a directory array as uint16_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_SHORT is returned as fetched; TIFF_SSHORT is range-checked in place. Other types are converted into a new array: TIFF_BYTE is widened, and any other element outside 0..UINT16_MAX fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 2294 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeShortLong(), TIFFReadDirEntryCheckRangeShortLong8(), TIFFReadDirEntryCheckRangeShortSbyte(), TIFFReadDirEntryCheckRangeShortSlong(), TIFFReadDirEntryCheckRangeShortSlong8(), TIFFReadDirEntryCheckRangeShortSshort(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfShort(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag(), TIFFReadDirectory(), and TIFFReadDirEntryPersampleShort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySlong()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong ( TIFF *  tif,
TIFFDirEntry *  direntry,
int32_t *  value 
)
static

Convert one directory value to int32_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_SLONG is copied and the 8- and 16-bit types widened; TIFF_LONG, TIFF_LONG8 and TIFF_SLONG8 are rejected with TIFFReadDirEntryErrRange unless the value is in INT32_MIN..INT32_MAX. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 958 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeSlongLong(), TIFFReadDirEntryCheckRangeSlongLong8(), TIFFReadDirEntryCheckRangeSlongSlong8(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySlong8()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8 ( TIFF *  tif,
TIFFDirEntry *  direntry,
int64_t *  value 
)
static

Convert one directory value to int64_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_SLONG8 is copied and the 8- to 32-bit types widened; TIFF_LONG8 values above INT64_MAX are rejected with TIFFReadDirEntryErrRange. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 1166 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeSlong8Long8(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySlong8Array()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array ( TIFF *  tif,
TIFFDirEntry *  direntry,
int64_t **  value 
)
static

Read a directory array as int64_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_SLONG8 is returned as fetched; TIFF_LONG8 is range-checked in place and an element above INT64_MAX fails with TIFFReadDirEntryErrRange. The 8- to 32-bit types are widened into a new array without checks. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 3337 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeSlong8Long8(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong8(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySlongArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
int32_t **  value 
)
static

Read a directory array as int32_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_SLONG is returned as fetched; TIFF_LONG is range-checked in place. Other types are converted into a new array: the 8- and 16-bit types are widened, and TIFF_LONG8/TIFF_SLONG8 elements outside INT32_MIN..INT32_MAX fail with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 2908 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeSlongLong(), TIFFReadDirEntryCheckRangeSlongLong8(), TIFFReadDirEntryCheckRangeSlongSlong8(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfLong(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySshort()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySshort ( TIFF *  tif,
TIFFDirEntry *  direntry,
int16_t *  value 
)
static

Convert one directory value to int16_t.

Requires count exactly one. Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. TIFF_SSHORT is copied and TIFF_BYTE/TIFF_SBYTE widened; the other types are rejected with TIFFReadDirEntryErrRange unless the value is in INT16_MIN..INT16_MAX. TIFF_LONG8 and TIFF_SLONG8 values are read from the file at the entry offset in classic TIFF (seeking unless memory-mapped) and from the inline entry bytes in BigTIFF; all other accepted types are inline. Performs no allocation and emits no diagnostics itself; errors are returned for the caller to report. *value is written only on success, except that an I/O failure can leave it partially written when it is the read destination.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL caller-owned scalar slot; valid only on TIFFReadDirEntryErrOk.
Returns
TIFFReadDirEntryErrOk on conversion, or the specific count/type/range/I/O error; no owned output.

Definition at line 739 of file tif_dirread.c.

References TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_type, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFFReadDirEntryCheckedByte(), TIFFReadDirEntryCheckedLong(), TIFFReadDirEntryCheckedLong8(), TIFFReadDirEntryCheckedSbyte(), TIFFReadDirEntryCheckedShort(), TIFFReadDirEntryCheckedSlong(), TIFFReadDirEntryCheckedSlong8(), TIFFReadDirEntryCheckedSshort(), TIFFReadDirEntryCheckRangeSshortLong(), TIFFReadDirEntryCheckRangeSshortLong8(), TIFFReadDirEntryCheckRangeSshortShort(), TIFFReadDirEntryCheckRangeSshortSlong(), TIFFReadDirEntryCheckRangeSshortSlong8(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, and TIFFReadDirEntryErrType.

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirEntrySshortArray()

static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray ( TIFF *  tif,
TIFFDirEntry *  direntry,
int16_t **  value 
)
static

Read a directory array as int16_t elements.

Accepts TIFF_BYTE, TIFF_SBYTE, TIFF_SHORT, TIFF_SSHORT, TIFF_LONG, TIFF_SLONG, TIFF_LONG8, TIFF_SLONG8. Fetches the raw elements with TIFFReadDirEntryArray() (inline bytes, or file data that may be sought and read when not memory-mapped) and swaps them to host order. TIFF_SSHORT is returned as fetched; TIFF_SHORT is range-checked in place. Other types are converted into a new array: TIFF_BYTE and TIFF_SBYTE are widened, and any other element outside INT16_MIN..INT16_MAX fails with TIFFReadDirEntryErrRange. On success *value receives a new allocation owned by the caller and released with _TIFFfreeExt(); a zero count succeeds with *value NULL. An existing allocation in *value is not freed. *value is set to NULL when the raw fetch fails; type, allocation and range errors leave it unchanged. Temporary buffers are freed on every error path. The oversized-request check and allocation failures emit diagnostics; other errors are only returned.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]direntryNon-NULL parsed entry with host-order tag/type/count and raw offset/inline bytes; borrowed only for this call.
[out]valueNon-NULL empty owner slot for the new element array; valid only on success.
Returns
TIFFReadDirEntryErrOk for a converted/empty array, or a type, range, size, allocation, or I/O error; only success transfers ownership.

Definition at line 2500 of file tif_dirread.c.

References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirEntry::tdir_type, tiff::tif_flags, TIFF_BYTE, TIFF_LONG, TIFF_LONG8, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SSHORT, TIFF_SWAB, TIFFReadDirEntryArray(), TIFFReadDirEntryCheckRangeSshortLong(), TIFFReadDirEntryCheckRangeSshortLong8(), TIFFReadDirEntryCheckRangeSshortShort(), TIFFReadDirEntryCheckRangeSshortSlong(), TIFFReadDirEntryCheckRangeSshortSlong8(), TIFFReadDirEntryErrAlloc, TIFFReadDirEntryErrOk, TIFFReadDirEntryErrType, TIFFSwabArrayOfShort(), TIFFSwabLong(), TIFFSwabLong8(), and TIFFSwabShort().

Referenced by TIFFFetchNormalTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadUInt64()

static uint64_t TIFFReadUInt64 ( const uint8_t *  value)
static

Copy eight unaligned bytes into a native uint64_t value.

Does not swap file byte order, allocate, validate the buffer extent, or transfer ownership; no handle state or diagnostics.

Parameters
[in]valueBorrowed readable buffer of at least eight bytes; no alignment required.
Returns
Native-order interpretation of the copied eight bytes.

Definition at line 353 of file tif_dirread.c.

References _UInt64Aligned_t::c, and _UInt64Aligned_t::l.

Referenced by TIFFFetchDirectory().

Here is the caller graph for this function: