Headline
CVE-2022-1122: Exist a issues of freeing uninitialized pointer in src/bin/jp2/opj_decompress.c,that will cause a segfault · Issue #1368 · uclouvain/openjpeg
A flaw was found in the opj2_decompress program in openjpeg2 2.4.0 in the way it handles an input directory with a large number of files. When it fails to allocate a buffer to store the filenames of the input directory, it calls free() on an uninitialized pointer, leading to a segmentation fault and a denial of service.
Hi,
I found a segmentation fault in current master, and I also reproduced it on latest released version 2.5.0.
Crash Summary:
A issues of freeing uninitialized pointer exist in src/bin/jp2/opj_decompress.c:1795 in main, it can lead to a segmentation fault via the POC provided below
Crash Analysis:
- run command: ./opj_decompress -ImgDir input -OutFor BMP
- If there are lots of files in the imgdir directory, that will cause memory malloc failure
- Then, since the pointer dirptr->filename is not initialized, free(dirptr->filename) is failed
GDB debugging results:
poc.zip