JonBCode / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Some memory allocation are not checked #355

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Some memory allocation are not checked.
This can cause a crash or memory corruption.

What is the expected output?
All malloc/calloc/realloc shall be checked

What version of the product are you using?
2.1.0

Please find 2 patch :
1 patch which adds a comment for each malloc/calloc/realloc not checked (only 
openjp2 lib)
1 patch which corrects the behaviour for opj_setup_encoder to return OPJ_FALSE 
in case of allocation failure

Original issue reported on code.google.com by m.darb...@gmail.com on 11 Jun 2014 at 10:55

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by m.darb...@gmail.com on 15 Sep 2014 at 2:11

GoogleCodeExporter commented 9 years ago
Hi,

Here's a patch that includes the openjpeg-2.1.0-setup-enc-return.patch and all 
memory checks (instead of just adding comments).
It also includes memory checks from 
https://github.com/OpenJPEG/openjpeg/commit/07a891b4ec682b30394e8e5db5913e6b7580
a2bf (some were not in the original comment patch)

The setup of the default comment string has changed. It's not added to user 
provided parameters but, instead, only to internal parameters. Before that, 
user could check that comment was added & read it but had no way to properly 
free this memory (opj_free being internal). The previous behaviour also lead to 
memory leaks if one doesn't check comment added by openjpeg (as can be seen on 
valgrind checks on CDash).

The test that was added for Issue 296 failed with the first version of the 
patch (not because of the patch for that matter). An overflow check is now done 
before comparing buffer bounds (t2.c, line 1135).

Patch verified (CDash MacOS x86,x64 + Local Windows vc10 x64)

Regards
Matthieu

Original comment by m.darb...@gmail.com on 17 Sep 2014 at 6:57

Attachments:

GoogleCodeExporter commented 9 years ago
I have also reviewed the patch and everything seems ok.
Many thanks Matthieu

Original comment by antonin on 19 Sep 2014 at 10:25

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2883.

Original comment by antonin on 19 Sep 2014 at 10:26