0008-opj_decompress-fix-double-free-on-input-directory-with-mix-of-valid.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From e8e258ab049240c2dd1f1051b4e773b21e2d3dc0 Mon Sep 17 00:00:00 2001
  2. From: Even Rouault <even.rouault@spatialys.com>
  3. Date: Sun, 28 Jun 2020 14:19:59 +0200
  4. Subject: [PATCH] opj_decompress: fix double-free on input directory with mix
  5. of valid and invalid images (CVE-2020-15389)
  6. Fixes #1261
  7. Credits to @Ruia-ruia for reporting and analysis.
  8. [Retrieved from:
  9. https://github.com/uclouvain/openjpeg/commit/e8e258ab049240c2dd1f1051b4e773b21e2d3dc0]
  10. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  11. ---
  12. src/bin/jp2/opj_decompress.c | 8 ++++----
  13. 1 file changed, 4 insertions(+), 4 deletions(-)
  14. diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
  15. index 7eeb0952f..2634907f0 100644
  16. --- a/src/bin/jp2/opj_decompress.c
  17. +++ b/src/bin/jp2/opj_decompress.c
  18. @@ -1316,10 +1316,6 @@ static opj_image_t* upsample_image_components(opj_image_t* original)
  19. int main(int argc, char **argv)
  20. {
  21. opj_decompress_parameters parameters; /* decompression parameters */
  22. - opj_image_t* image = NULL;
  23. - opj_stream_t *l_stream = NULL; /* Stream */
  24. - opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
  25. - opj_codestream_index_t* cstr_index = NULL;
  26. OPJ_INT32 num_images, imageno;
  27. img_fol_t img_fol;
  28. @@ -1393,6 +1389,10 @@ int main(int argc, char **argv)
  29. /*Decoding image one by one*/
  30. for (imageno = 0; imageno < num_images ; imageno++) {
  31. + opj_image_t* image = NULL;
  32. + opj_stream_t *l_stream = NULL; /* Stream */
  33. + opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
  34. + opj_codestream_index_t* cstr_index = NULL;
  35. if (!parameters.quiet) {
  36. fprintf(stderr, "\n");