4998 Commits

Author SHA1 Message Date
Roger Leigh
61b5551e0c Merge branch 'fix_ossfuzz_471945501' into 'master'
JPEGDecode(): fix memory leak in error code path

See merge request libtiff/libtiff!803
2025-12-27 18:58:35 +00:00
Even Rouault
cfaeb1e7a5 JPEGDecode(): fix memory leak in error code path
Fixes https://issues.oss-fuzz.com/issues/471945501
2025-12-27 18:32:54 +01:00
Even Rouault
628e1d8028 Merge branch 'warning-additions' into 'master'
ci: Build CMake builds with extra-warnings

See merge request libtiff/libtiff!798
2025-12-25 18:22:22 +00:00
Roger Leigh
d725d13f14 Merge branch 'ossfuzz_471472003' into 'master'
TIFFFillStrip(): prevent harmless unsigned integer overflow

See merge request libtiff/libtiff!801
2025-12-25 16:11:32 +00:00
Even Rouault
a829e24c51 TIFFFillStrip(): prevent harmless unsigned integer overflow
Fixes https://issues.oss-fuzz.com/issues/471472003
2025-12-25 10:31:49 +01:00
Roger Leigh
61c30c146c Merge branch 'fix_ossfuzz_471328917' into 'master'
_TIFFGetStrileOffsetOrByteCountValue(): fix potential crash on corrupted files...

See merge request libtiff/libtiff!799
2025-12-24 14:27:11 +00:00
Roger Leigh
9a2de8115c Correct -Wformat errors
Fix format string mismatches where the format specifier doesn't match
the argument type:

- Change %d to %u for unsigned int/uint32_t arguments
- Change %u to %d for signed int arguments
- Add casts where needed for printf family functions
- Use PRIu64/PRIi64 for uint64_t/int64_t arguments

Fix -Wformat-nonliteral warnings

Add TIFF_ATTRIBUTE((__format__(__printf__, N, 0))) to functions that
accept format strings as parameters (va_list style). The 0 indicates
no variadic arguments to check since the format is validated at the
call site.
2025-12-24 13:49:08 +00:00
Roger Leigh
f5f4dced8f Correct -pedantic errors
* Missing void in function declarations
* Extra semicolons
2025-12-24 13:49:08 +00:00
Roger Leigh
81b28ece04 ci: Build CMake builds with extra-warnings
* Split extra-warnings into extra-warnings and broken-warnings
* extra-warnings initially only uses -pedantic -Wextra
* Warnings will be moved from broken-warnings to extra-warnings
  once the CI builds have proved them safe to use
2025-12-24 13:49:08 +00:00
Roger Leigh
8f45767f46 ci: Pre-build is static
* Includes additional test source files
2025-12-24 12:15:20 +00:00
Even Rouault
9b97b2acfa _TIFFGetStrileOffsetOrByteCountValue(): fix potential crash on corrupted files when file opened in 'O' mode
Fixes https://issues.oss-fuzz.com/issues/471328917
2025-12-24 11:48:11 +01:00
Even Rouault
b6995387ca Merge branch 'typo_fix' into 'master'
tif_dirread.c: fix typo in code comment (master only)

See merge request libtiff/libtiff!797
2025-12-23 20:03:27 +00:00
Even Rouault
a82a0089cf tif_dirread.c: fix typo in code comment (master only) 2025-12-23 18:59:16 +01:00
Roger Leigh
2462ee36dc Merge branch 'fix_ossfuzz_470691578' into 'master'
TIFFReadDirectory(): re-set TIFF_LAZYSTRILELOAD if file opened in 'O' mode

See merge request libtiff/libtiff!793
2025-12-22 22:28:20 +00:00
Even Rouault
7e79e2ab24 Rework TIFF_LAZYSTRILELOAD flag 2025-12-22 18:01:07 +01:00
Even Rouault
47d2f81e9d TIFFReadDirectory(): re-set TIFF_LAZYSTRILELOAD if file opened in 'O' mode
This fixes a potential heap write buffer overflow when reading a
corrupted file, with multiple IFDs, and when iterating over those IFDs,
and when the file was opened in 'O' mode.

Fixes https://issues.oss-fuzz.com/issues/470691578
2025-12-22 02:01:23 +01:00
Roger Leigh
6f641bbce2 Merge branch 'ci-vcpkg' into 'master'
ci: Use vcpkg installation specific to libtiff

See merge request libtiff/libtiff!792
2025-12-21 18:35:33 +00:00
Roger Leigh
c858490ce1 ci: Use vcpkg installation specific to libtiff 2025-12-21 17:33:55 +00:00
Roger Leigh
46b4deec99 Merge branch 'cpp-check' into 'master'
Add explicit casts for void* and int-to-enum conversions

See merge request libtiff/libtiff!791
2025-12-21 16:42:07 +00:00
Roger Leigh
3aac487624 ci: enforce MSVC /W4 warnings 2025-12-21 10:51:28 +00:00
Roger Leigh
738d882a19 Correct MSVC /W4 warnings
* Shadowing (add local_ prefix)
* Conversion (add casts)
* Initialisation (initialise with value)
2025-12-21 10:51:26 +00:00
Roger Leigh
99466f4173 tif_dirinfo: Restore MSVC warning disable 4132 2025-12-20 22:51:01 +00:00
Roger Leigh
334807ce6d ci: Run compatibility checks before main builds 2025-12-20 14:32:42 +00:00
Roger Leigh
440676cc63 Allow tif_jbig to compile with C++ compiler 2025-12-20 14:31:20 +00:00
Roger Leigh
29c5dead27 cmake: Improve tiff_target_compile_as_cxx implementation 2025-12-20 12:55:28 +00:00
Roger Leigh
e2c0559912 tif_dir: Correct C++ circular dependency warning 2025-12-20 11:13:53 +00:00
Roger Leigh
5222885b6b ci: Test C++ compatibility mode 2025-12-18 22:35:08 +00:00
Roger Leigh
e8459c5ad1 Add CMake options for C++ compatibility checking
Add two new CMake options to help maintain C++ compatibility:

1. cxx-compat-warnings: Enables -Wc++-compat flag (GCC/Clang) which
   warns about using C++ keywords as identifiers and some enum/int
   conversions. This is limited and won't catch all issues.

2. cxx-compat-mode: Compiles C source files as C++17 using -x c++
   (GCC/Clang) or /TP (MSVC). This catches all C++ incompatibilities
   as compile errors, including:
   - implicit void* to typed pointer conversions
   - register storage class (removed in C++17)
   - goto/switch jumping over variable initialization
   - enum arithmetic and implicit conversions

Usage:
  cmake -Dcxx-compat-warnings=ON ..  # Light checking
  cmake -Dcxx-compat-mode=ON ..      # Full C++ compilation
2025-12-18 22:35:00 +00:00
Roger Leigh
8fdc101095 Fix remaining C++ compatibility issues
- tif_compress.c: Cast const away for strcpy to initialized const char* field
- tif_jpeg.c: Add unsigned short* cast for malloc result
- tif_ojpeg.c: Add JSAMPARRAY and JSAMPIMAGE casts for jpeg functions
- tif_print.c: Change sep variable from char* to const char*
- mkspans.c: Convert K&R style functions to ANSI C, add return type to main
2025-12-18 22:34:58 +00:00
Roger Leigh
20d5e5401d Add more explicit void* to typed pointer casts in tools
Additional C++ compatibility fixes for implicit void* to typed pointer
conversions that are not allowed in C++. These files had function calls
where void* (tdata_t) was passed to functions expecting typed pointers
like uint8_t* or unsigned char*.
2025-12-18 22:34:53 +00:00
Roger Leigh
02d0c2949f Add explicit casts for void* and int-to-enum conversions
C++ is stricter about type conversions than C:

1. void* to typed pointer: In C++ you cannot implicitly convert void*
   to a typed pointer. Add explicit casts for custom tag value pointers
   passed to TIFFWriteDirectoryTag* functions.

2. Integer to enum: C++ requires explicit casts when assigning integer
   types to enum types. Add casts for:
   - TIFFDataWidth() calls where tdir_type (uint16_t) is passed
   - TIFFDataType assignments from uint16_t entry_type

Files modified:
- tif_dirwrite.c: Cast td_customValues[m].value to appropriate types
  for each TIFF type (char*, uint8_t*, int8_t*, uint16_t*, etc.)
  and cast entry_type to TIFFDataType where needed
- tif_dirread.c: Cast tdir_type to TIFFDataType for TIFFDataWidth calls
2025-12-18 22:34:49 +00:00
Roger Leigh
99c0159738 Merge branch 'ci-windows' into 'master'
ci: Add Windows builds

See merge request libtiff/libtiff!790
2025-12-18 21:54:31 +00:00
Roger Leigh
1e1508a43b Add .gitattributes 2025-12-17 09:44:54 +00:00
Roger Leigh
b1c7fb0f70 ci: Corrections for Cygwin and MinGW builds 2025-12-17 09:17:27 +00:00
Roger Leigh
2584a8c473 ci: Restrict most jobs to libtiff/libtiff 2025-12-17 00:08:34 +00:00
Roger Leigh
4526df4a0a ci: Add Windows builds 2025-12-16 19:24:28 +00:00
Roger Leigh
3a1eaaffce ci: Drop AppVeyor use 2025-12-16 14:13:32 +00:00
Even Rouault
4f1fb36df3 Merge branch 'TIFFReadDirEntryPersampleShort_zero' into 'master'
TIFFReadDirEntryPersampleShort(): reject tags with tdir_count=0 (master only)

Closes #764

See merge request libtiff/libtiff!788
2025-12-16 09:34:10 +00:00
Even Rouault
f0c04cf94a Merge branch 'tiffFieldArray_msvc_warning' into 'master'
tif_dirinfo.c: re-add MSVC warning suppression (master only)

See merge request libtiff/libtiff!789
2025-12-16 09:33:50 +00:00
Even Rouault
3a07da8b24 tif_dirinfo.c: re-add MSVC warning suppression (master only)
It has been removed by a recent commit, but is still needed to get a
warning free build when using most verbose warning levels.
2025-12-16 01:30:17 +01:00
Even Rouault
fe01e19b9d TIFFReadDirEntryPersampleShort(): reject tags with tdir_count=0 (master only)
This amends commit b8fda5eeb8 that could
lead to reading uninitialized variables.

Fixes #764
2025-12-16 00:26:32 +01:00
Roger Leigh
64ec0a8d8c Merge branch 'ci-linux' into 'master'
ci: Use Linux Docker runner

See merge request libtiff/libtiff!787
2025-12-15 23:01:34 +00:00
Roger Leigh
3ca3e70a2c ci: Use Linux Docker runner 2025-12-15 21:42:20 +00:00
Roger Leigh
385aff84bf Merge branch 'ci-macos' into 'master'
ci: Add MacOS and FreeBSD builds

See merge request libtiff/libtiff!786
2025-12-15 17:03:37 +00:00
Roger Leigh
df2d677045 ci: Add MacOS and FreeBSD builds 2025-12-15 15:14:14 +00:00
Roger Leigh
d38bda3199 Merge branch 'fix-enum-cpp-compat' into 'master'
Fix enum-related C++ compatibility issues

See merge request libtiff/libtiff!785
2025-12-14 18:52:42 +00:00
Roger Leigh
2c36e1c9bf Merge branch 'fix-goto-variable-init' into 'master'
Fix goto bypassing variable initialisation

See merge request libtiff/libtiff!783
2025-12-14 12:12:57 +00:00
Roger Leigh
cd73042e81 Merge remote-tracking branch 'origin/master' into fix-goto-variable-init 2025-12-14 09:19:06 +00:00
Roger Leigh
9f4fad3f15 Merge branch 'explicit-cast-void-pointer' into 'master'
Add explicit casts for void* to typed pointer conversions

See merge request libtiff/libtiff!782
2025-12-14 09:17:33 +00:00
Roger Leigh
1ee7a6f845 Merge branch 'const-char-literals-data' into 'master'
Use const char* for string literals and const data

See merge request libtiff/libtiff!781
2025-12-14 09:17:10 +00:00