Exist a undefined-behavior issue in file src/lib/openjp2/tcd.c:2327
xiaoxiaoafeifei opened this issue · 0 comments
Expected behavior and actual behavior.
Hi,
I found a runtime error: applying zero offset to null pointer in current master, and I also reproduced it on latest released version 2.5.0.
Steps to reproduce the problem.
git clone https://github.com/uclouvain/openjpeg.git
cd openjpeg
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_FLAGS="-fsanitize=undefined"
-DCMAKE_CXX_FLAGS="-fsanitize=undefined"
make
./bin/opj_decompress -o res.bmp -r 5 -i poc_file
poc_file:
poc_file.zip
Reproduction
root@iZ2vcadn43p7fjzbhl6zqwZ:~#./openjpeg/build/bin/opj_decompress -o res.bmp -r 5 -i poc_file
===========================================
The extension of this file is incorrect.
FOUND ep:8. SHOULD BE .j2k or .jpc or .j2c or .jhc
[INFO] Start to read j2k main header (0).
[INFO] Main header has been correctly decoded.
[INFO] No decoded area parameters, set the decoded area to the whole image
[INFO] Header of tile 1 / 1 has been read.
/root/fuzz_pro/fuzz_openjpeg/openjpeg/src/lib/openjp2/tcd.c:2327:31: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /root/fuzz_pro/fuzz_openjpeg/openjpeg/src/lib/openjp2/tcd.c:2327:31 in
[INFO] Tile 1/1 has been decoded.
[INFO] Image data has been updated with tile 1.
[WARNING] Failed to decode component 0
[WARNING] Failed to decode component 1
[WARNING] Failed to decode component 2
[WARNING] Failed to decode component 3
[ERROR] Failed to decode all used components
ERROR -> opj_decompress: failed to decode image
Operating system
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
openjpeg version
currrent master version