Skip to content

Fix: HBO in CTiffImg::WriteLine()#686

Merged
xsscx merged 1 commit intomasterfrom
issue-672
Mar 15, 2026
Merged

Fix: HBO in CTiffImg::WriteLine()#686
xsscx merged 1 commit intomasterfrom
issue-672

Conversation

@ChrisCoxArt
Copy link
Contributor

And always calculate bytesPerSample
And make the output buffer calc easier to debug
Fixes #672

Pull Request Checklist

  • Have you followed the guidelines in Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you built your Pull Request locally with the Build Instructions?
  • Have you added or updated relevant tests?
  • Have you added or updated relevant docs?

And always calculate bytesPerSample
And make the output buffer calc easier to debug
Fixes #672
@ChrisCoxArt ChrisCoxArt requested a review from xsscx as a code owner March 15, 2026 00:58
@xsscx xsscx self-assigned this Mar 15, 2026
@xsscx xsscx added PR Pull Request Review in Process Issue is being Reviewed by Maintainers and removed pending labels Mar 15, 2026
@xsscx xsscx changed the title calc the output line size, don't use the input size Fix: HBO in CTiffImg::WriteLine() Mar 15, 2026
@xsscx
Copy link
Member

xsscx commented Mar 15, 2026

Status

2026-03-15 01:13:15 UTC

@ChrisCoxArt Do you want me to roll this into a new issue after the Merge of do you want to fix it this PR?

Your choice.. will Merge if you are busy and open a Issue.

Thank You!!

[2026-03-15 01:13:15 UTC] ~/pr-686/iccDEV/Testing (pr-686)$ ASAN_OPTIONS=print_scariness=1 iccSpecSepToTiff hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.icc 0 0 hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif 0 0 1
TIFFReadDirectory: Warning, Unknown field with tag 14645 (0x3935) encountered.
TIFFFetchNormalTag: Warning, Incorrect count for "PhotometricInterpretation"; tag ignored.
_TIFFVSetField: hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif: Bad value 69 for "ResolutionUnit" tag.
TIFFFetchNormalTag: Defined set_field_type of custom tag 14645 (Tag 14645) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFReadDirectory: Warning, Bogus "StripByteCounts" field, ignoring and calculating from imagelength.
Image successfully written!
=================================================================
==14727==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x502000000130
SCARINESS: 10 (alloc-dealloc-mismatch)
    #0 0x5a534eb1f2a1 in operator delete(void*) (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x10e2a1) (BuildId: b411f547367059e067c3502d18b22db757879584)
    #1 0x5a534eb25373 in std::default_delete<unsigned char>::operator()(unsigned char*) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:99:2

Copy link
Member

@xsscx xsscx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer Review

2026-03-15 01:15:58 UTC

Repro

mkdir pr-686
cd pr-686
git clone https://github.com/InternationalColorConsortium/iccDEV.git
cd iccDEV/Build
git fetch origin pull/686/head:pr-686
git checkout pr-686
export CXX=clang++ && export CXXFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g -O1 -fprofile-arcs -ftest-coverage" && export LDFLAGS="-fsanitize=address,undefined -fprofile-arcs" && cmake Cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_UBSAN=ON -DENABLE_COVERAGE=ON
make -j$(nproc)
        cd ../Testing/
        echo "=== Updating PATH ==="
         for d in ../Build/Tools/*; do
          [ -d "$d" ] && export PATH="$(realpath "$d"):$PATH"
         done
wget https://github.com/xsscx/fuzz/raw/refs/heads/master/graphics/tif/hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif
wget https://github.com/xsscx/fuzz/raw/refs/heads/master/graphics/icc/hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.icc
ASAN_OPTIONS=print_scariness=1 iccSpecSepToTiff hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.icc 0 0 hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif 0 0 1 

PR Application Output

[2026-03-15 01:13:15 UTC] ~/pr-686/iccDEV/Testing (pr-686)$ ASAN_OPTIONS=print_scariness=1 iccSpecSepToTiff hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.icc 0 0 hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif 0 0 1
TIFFReadDirectory: Warning, Unknown field with tag 14645 (0x3935) encountered.
TIFFFetchNormalTag: Warning, Incorrect count for "PhotometricInterpretation"; tag ignored.
_TIFFVSetField: hbo-CTiffImg-WriteLine-TiffImg_cpp-Line411.tif: Bad value 69 for "ResolutionUnit" tag.
TIFFFetchNormalTag: Defined set_field_type of custom tag 14645 (Tag 14645) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFReadDirectory: Warning, Bogus "StripByteCounts" field, ignoring and calculating from imagelength.
Image successfully written!
=================================================================
==14727==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x502000000130
SCARINESS: 10 (alloc-dealloc-mismatch)
    #0 0x5a534eb1f2a1 in operator delete(void*) (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x10e2a1) (BuildId: b411f547367059e067c3502d18b22db757879584)
    #1 0x5a534eb25373 in std::default_delete<unsigned char>::operator()(unsigned char*) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:99:2
    #2 0x5a534eb25373 in std::unique_ptr<unsigned char, std::default_delete<unsigned char>>::~unique_ptr() /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:404:4
    #3 0x5a534eb23bf3 in main /home/h02332/pr-686/iccDEV/Tools/CmdLine/IccSpecSepToTiff/iccSpecSepToTiff.cpp:273:1
    #4 0x76cc9da2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #5 0x76cc9da2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #6 0x5a534ea455b4 in _start (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x345b4) (BuildId: b411f547367059e067c3502d18b22db757879584)

0x502000000130 is located 0 bytes inside of 4-byte region [0x502000000130,0x502000000134)
allocated by thread T0 here:
    #0 0x5a534eb1eb41 in operator new[](unsigned long) (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x10db41) (BuildId: b411f547367059e067c3502d18b22db757879584)
    #1 0x5a534eb22a5f in main /home/h02332/pr-686/iccDEV/Tools/CmdLine/IccSpecSepToTiff/iccSpecSepToTiff.cpp:209:45
    #2 0x76cc9da2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #3 0x76cc9da2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #4 0x5a534ea455b4 in _start (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x345b4) (BuildId: b411f547367059e067c3502d18b22db757879584)

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/home/h02332/pr-686/iccDEV/Build/Tools/IccSpecSepToTiff/iccSpecSepToTiff+0x10e2a1) (BuildId: b411f547367059e067c3502d18b22db757879584) in operator delete(void*)
==14727==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==14727==ABORTING

@xsscx xsscx added Pending Merge Maintainer indicates Merge Pending and requests no further changes and removed Review in Process Issue is being Reviewed by Maintainers labels Mar 15, 2026
@ChrisCoxArt
Copy link
Contributor Author

New issue, please - I'll have to chase down all the allocating paths.

@xsscx xsscx merged commit afb975c into master Mar 15, 2026
27 checks passed
@xsscx xsscx removed the Pending Merge Maintainer indicates Merge Pending and requests no further changes label Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HBO in CTiffImg::WriteLine() at TiffImg.cpp:411

2 participants