-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cppcheck static analysis #719
Comments
On current master (5c5ae1d) I get :
|
So the main component (lib/openjp2 and bin/jp2) are almost cppcheck-free. I did not understand the |
using cppcheck-1.73, I have made a cppckeck on the whole openjpeg-master-2016-04-13 library. Without directories: Skipped: Unsolved: Problems: Most malloc/calloc/realloc tests have been done. The resulting DIF file is 176'715 Bytes large. The worst library is the JP3D library. Followed by the JPIP library. Does anybody work on cppckeck tests? Then I would give up. winfried |
@szukw000 , not sure to understand : you have a patch ready for fixing some cppcheck warnings ? |
@julienmalik : yes, I have a patch. But it is not complete. And before I spend more time I would winfried |
@julienmalik, the attached file shows some problems. cidx_manager.c, ppix_manager.c, thix_manager.c: they return a length of 0 E.g. in line 88, cidx_manager.c:
In opj_write_manf() this length is written:
What is the effect if a length of 0 is met anywhere? In j2k.c the condition
is reduced to because of '!JPWL_ASSUME == JPWL_ASSUME'. What is the result of the correction?
JPWL_ASSUME means EVT_WARNING, !JPWL_ASSUME means EVT_ERROR.
In jp2.c, line 646 ff, jp2 first is used, then checked whether it is NULL. The cielab test at line 1408:
has been reported as a fix elsewhere. The fix has never been applied. winfried |
Here is the full patch. winfried |
What the UBUNTU people have criticised is true. The OPENJPEG library Some comments. src/lib/openmj2/j2k.c: if (!JPWL_ASSUME || JPWL_ASSUME) does mean the same. So with opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR, only if (!JPWL_ASSUME) is used. src/lib/openjpip: To remove in src/lib/openjpip undefined reference to `opj_malloc' I added in CMakeLists.txt '${OPENJPEG_LIBRARY_NAME}' if(BUILD_JPIP_SERVER) and in some H.files #include "opj_includes.h" At several places after 'return' the comment /* FIXME szukw000 */ has been added. The FIXME shall remember that it remains unclear what With 'return;' only it may happen that a 'delete_FUNC()' tries to Some bugs are very, very old. Patches have been ignored. E.g. src/lib/openmj2/mj2.h
This ignorance does not make the library more safe. The 'src/bin/fltk/flviewer' has been added as Antonin wanted a winfried linux-cmake-build-flviewer.sh: #!/bin/sh win32-cmake-build-flviewer.bat: cmake -G "NMake Makefiles" -DBUILD_DOC:bool=off -DBUILD_PKGCONFIG_FILES:bool=off -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_FLVIEWER:bool=on -DBUILD_FLVIEWER_WITH_SHARED_LIBS:bool=on -DBUILD_JAVA:bool=off -DBUILD_JPIP_SERVER:bool=on -DBUILD_SHARED_LIBS:bool=on -DBUILD_MJ2:bool=on -DBUILD_JP3D:bool=on -DBUILD_JPWL:bool=on -DBUILD_JPIP:bool=on -DCMAKE_INSTALL_PREFIX:path="C:/Users/Public" -DFLTK_SKIP_OPENGL:bool=on -DBUILD_WITH_GERMAN:bool=off .. |
Maybe it is more convenient to propose a cppcheck message as a single issue because it is easier to fix one file and test. As well there is some kind of four eyes principle and more people can supply (of course smaller) patches. |
I just re-checked openjpeg-2.1.1 with cppcheck 1.72 and the results are significantly better: $ cppcheck -q -j30 . Thanks for fixing the other issues; it'd sure be nice to bring this list down to zero. Thanks |
Hello, I inspected OpenJPEG for the Ubuntu Linux distribution; as part of my review I ran the cppcheck static analysis tool on the 1.5.2 and 2.1.0 sources. I only inspected the 1.5.2 results (what is currently packaged in Ubuntu) and found most of the results looked legitimate with only a few false positives.
I did not inspect the 2.1.0 results beyond noticing that many looked similar to valid issues from 1.5.2.
I strongly recommend fixing all these issues -- many represent real bugs in the program that may be difficult to discover via other methods. It is worth fixing all the reported issues -- even the ones that represent FILE leaks when main() prematurely terminates -- as it makes it far easier to prevent new issues from entering the codebase when the output is usually clean.
Here's the list of issues it found:
[src/bin/jp2/opj_compress.c:1599]: (error) Memory leak: dirptr
[src/bin/jp2/opj_compress.c:1060]: (error) Memory leak: lMatrix
[src/bin/jp2/opj_compress.c:1599]: (error) Memory leak: parameters.cp_comment
[src/bin/jp2/opj_decompress.c:720]: (error) Memory leak: dirptr
[src/bin/jp2/opj_compress.c:631]: (error) Uninitialized variable: raw_signed
[src/bin/jp2/convert.c:130]: (error) Memory leak: tga
[src/bin/jp2/convert.c:1324]: (error) Resource leak: f
[src/bin/jp2/opj_dump.c:453]: (error) Memory leak: dirptr
[src/bin/jp2/convert.c:1880]: (error) Resource leak: fp
[src/bin/jp2/convert.c:3061]: (error) Resource leak: f
[src/bin/jp2/opj_dump.c:439]: (error) Memory leak: l_data
[src/bin/jp2/opj_dump.c:453]: (error) Memory leak: l_data
[src/bin/jp2/opj_dump.c:461]: (error) Memory leak: l_data
[src/bin/jp2/opj_dump.c:466]: (error) Memory leak: l_data
[src/bin/jp2/opj_dump.c:477]: (error) Memory leak: l_data
[src/bin/jp3d/convert.c:300]: (error) Resource leak: f
[src/bin/jp3d/convert.c:690]: (error) Resource leak: fdest
[src/bin/jpwl/convert.c:130]: (error) Memory leak: tga
[src/bin/jpwl/convert.c:1302]: (error) Resource leak: f
[src/bin/jpwl/convert.c:434]: (error) Resource leak: fdest
[src/bin/jpwl/convert.c:714]: (error) Resource leak: IN
[src/bin/jpwl/convert.c:1462]: (error) Resource leak: fdest
[src/bin/jpwl/convert.c:1437]: (error) Memory leak: name
[src/bin/jpwl/convert.c:2889]: (error) Resource leak: f
[src/bin/jpwl/opj_jpwl_compress.c:420]: (error) Memory leak: fname
[src/bin/jpwl/opj_jpwl_compress.c:1562]: (error) Memory leak: dirptr
[src/bin/jpwl/opj_jpwl_decompress.c:564]: (error) Memory leak: dirptr
[src/bin/jpwl/opj_jpwl_compress.c:1728]: (error) Resource leak: f
[src/bin/jpwl/opj_jpwl_compress.c:1789]: (error) Resource leak: f
[src/bin/jpwl/opj_jpwl_compress.c:1562]: (error) Memory leak: parameters.cp_comment
[src/bin/mj2/meta_out.c:684]: (error) fprintf format string requires 1 parameter but only 0 are given.
[src/bin/mj2/meta_out.c:702]: (error) fprintf format string requires 1 parameter but only 0 are given.
[src/bin/mj2/mj2_to_metadata.c:269]: (error) Resource leak: file
[src/bin/mj2/meta_out.c:1836]: (error) Invalid number of character '(' when these macros are defined: 'NOTYET'.
[src/bin/mj2/opj_mj2_compress.c:691]: (error) Resource leak: mj2file
[src/bin/mj2/opj_mj2_decompress.c:101]: (error) Resource leak: outfile
[src/bin/mj2/opj_mj2_decompress.c:161]: (error) Common realloc mistake: 'frame_codestream' nulled but not freed upon failure
[src/bin/mj2/opj_mj2_extract.c:140]: (error) Memory leak: frame_codestream
[src/bin/wx/OPJViewer/source/OPJThreads.cpp:892]: (error) Mismatching allocation and deallocation: buffer
[src/bin/wx/OPJViewer/source/wxj2kparser.cpp:188]: (error) Array 'marker_val[19]' accessed at index 23, which is out of bounds.
[src/bin/wx/OPJViewer/source/wxj2kparser.cpp:188]: (error) Array 'marker_val[20]' accessed at index 23, which is out of bounds.
[src/bin/wx/OPJViewer/source/wxj2kparser.cpp:188]: (error) Array 'marker_val[23]' accessed at index 23, which is out of bounds.
[src/lib/openjp2/j2k.c:8264]: (error) Memory leak: cstr_index
[src/lib/openjp2/j2k.c:3762]: (error) Invalid number of character '{' when these macros are defined: 'CLEAN_MSD'.
[src/lib/openjp3d/jp3d.c:1018]: (error) Uninitialized variable: numbands
[src/lib/openjp3d/tcd.c:1560]: (error) Uninitialized variable: l
[src/lib/openjp3d/tcd.c:1570]: (error) Uninitialized variable: l
[src/lib/openjpip/j2kheader_manager.c:120]: (error) Uninitialized variable: COD
[src/lib/openmj2/j2k.c:1548]: (error) Common realloc mistake: 'data' nulled but not freed upon failure
[src/lib/openmj2/mj2.c:1456]: (error) Array 'tk.urn[urn_num].name[2]' accessed at index 2, which is out of bounds.
[src/lib/openmj2/mj2.c:1457]: (error) Array 'tk.urn[urn_num].name[2]' accessed at index 3, which is out of bounds.
[src/lib/openmj2/mj2.c:1494]: (error) Array 'tk.urn[urn_num].name[2]' accessed at index 2, which is out of bounds.
[src/lib/openmj2/mj2.c:1495]: (error) Array 'tk.urn[urn_num].name[2]' accessed at index 3, which is out of bounds.
[src/lib/openmj2/mj2.c:2709]: (error) Common realloc mistake: 'src' nulled but not freed upon failure
[src/lib/openmj2/mj2.c:2713]: (error) Memory leak: src
[src/lib/openmj2/mj2_convert.c:63]: (error) Resource leak: f
[tests/test_tile_encoder.c:239]: (error) Memory leak: l_data
[thirdparty/libtiff/tif_luv.c:587]: (error) Shifting 32-bit value by 32 bits is undefined behaviour
[thirdparty/libz/gzread.c:345]: (error) Uninitialized variable: n
[thirdparty/libz/gzwrite.c:137]: (error) Uninitialized variable: n
[thirdparty/libz/inflate.c:1475]: (error) Shifting a negative value is undefined behaviour
Thanks
The text was updated successfully, but these errors were encountered: