From 9c911c0e1ee4367207cc9654ef109fb7250c5969 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 16 Sep 2015 20:49:45 +0200 Subject: [PATCH 1/8] Update the version number --- doc/man/man1/opj_compress.1 | 2 +- doc/man/man1/opj_decompress.1 | 2 +- doc/man/man1/opj_dump.1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/man/man1/opj_compress.1 b/doc/man/man1/opj_compress.1 index 51e5b1a5..cb37a427 100644 --- a/doc/man/man1/opj_compress.1 +++ b/doc/man/man1/opj_compress.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_compress 1 "Version 1.4.0" "opj_compress" "converts to jpeg2000 files" +.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files" .P .SH NAME opj_compress - diff --git a/doc/man/man1/opj_decompress.1 b/doc/man/man1/opj_decompress.1 index 470fd3c1..38a404a4 100644 --- a/doc/man/man1/opj_decompress.1 +++ b/doc/man/man1/opj_decompress.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_decompress 1 "Version 1.4.0" "opj_decompress" "converts jpeg2000 files" +.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files" .P .SH NAME opj_decompress - diff --git a/doc/man/man1/opj_dump.1 b/doc/man/man1/opj_dump.1 index a6033c61..160af63a 100644 --- a/doc/man/man1/opj_dump.1 +++ b/doc/man/man1/opj_dump.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_dump 1 "Version 1.4.0" "opj_dump" "dumps jpeg2000 files" +.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files" .P .SH NAME opj_dump - From 6cb56b36f627194fdfb13e306d27925b956af63f Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 16 Sep 2015 20:54:34 +0200 Subject: [PATCH 2/8] Update opj_decompress man page --- doc/man/man1/opj_decompress.1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/man/man1/opj_decompress.1 b/doc/man/man1/opj_decompress.1 index 38a404a4..1e7b6c54 100644 --- a/doc/man/man1/opj_decompress.1 +++ b/doc/man/man1/opj_decompress.1 @@ -73,9 +73,19 @@ n is the maximum number of quality layers to decode. See LAYERS below) .B \-\^OutFor "ext" (extension for output files) .P +.SH JPIP OPTIONS +Options usable only if the library has been compiled with +.B BUILD_JPIP +.TP +.B -jpip +Embed index table box into the output JP2 file (compulsory for JPIP) +.TP +.B -TP R +Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream) +.P .SH JPWL OPTIONS Options usable only if the library has been compiled with -.B -DUSE_JPWL +.B BUILD_JPWL .TP .B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3) .TP From a4e93c3b0af1c42770206b5d25014a05a60ec8f5 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:31:18 +0200 Subject: [PATCH 3/8] fix resource leak in opj_j2k_decode_one_tile Fixes #597 --- src/lib/openjp2/j2k.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index d487d89d..e733c645 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -9668,14 +9668,14 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k, * so move to the last SOT read */ if ( !(opj_stream_read_seek(p_stream, p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos+2, p_manager)) ){ opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); - opj_free(l_current_data); + opj_free(l_current_data); return OPJ_FALSE; } } else{ if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos+2, p_manager)) ) { opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); - opj_free(l_current_data); + opj_free(l_current_data); return OPJ_FALSE; } } @@ -9733,6 +9733,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k, /* move into the codestream to the the first SOT (FIXME or not move?)*/ if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) { opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); + opj_free(l_current_data); return OPJ_FALSE; } break; From c16c91797f4b15eb55d56f85fd497d588331e71f Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:41:41 +0200 Subject: [PATCH 4/8] Fix resource leak in opj_j2k_encode Fixes #598 --- src/lib/openjp2/j2k.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index e733c645..ec3635b6 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -9999,11 +9999,15 @@ OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k, /* now copy this data into the tile component */ if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) { opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." ); + opj_free(l_current_data); return OPJ_FALSE; } } if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) { + if (l_current_data) { + opj_free(l_current_data); + } return OPJ_FALSE; } } From 55dbf8acff9afab1591b6a094b744d8426a32dd4 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:46:42 +0200 Subject: [PATCH 5/8] Fix resource leak in opj_j2k_create_cstr_index Fixes #599 --- src/lib/openjp2/j2k.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index ec3635b6..f7a1d764 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -8603,8 +8603,10 @@ static opj_codestream_index_t* opj_j2k_create_cstr_index(void) cstr_index->marknum = 0; cstr_index->marker = (opj_marker_info_t*) opj_calloc(cstr_index->maxmarknum, sizeof(opj_marker_info_t)); - if (!cstr_index-> marker) + if (!cstr_index-> marker) { + opj_free(cstr_index); return NULL; + } cstr_index->tile_index = NULL; From 281537851b369e51bdaa8445014998c6b86c962b Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 17 Sep 2015 14:24:06 +0200 Subject: [PATCH 6/8] Add Coverity Scan status --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65d37979..17b8957b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Anyone. As the OpenJPEG code is released under the [2-clauses BSD license](https API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec). ## Current Status -* Build status: [![Build Status](https://travis-ci.org/uclouvain/openjpeg.svg?branch=master)](https://travis-ci.org/uclouvain/openjpeg) +[![Build Status](https://travis-ci.org/uclouvain/openjpeg.svg?branch=master)](https://travis-ci.org/uclouvain/openjpeg) + +[![Coverity Scan Build Status](https://scan.coverity.com/projects/6383/badge.svg)](https://scan.coverity.com/projects/uclouvain-openjpeg) ## Who are the developers ? From faf63fddad6efab9fa4dcb14cd290766722a7eec Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 23 Sep 2015 21:09:19 +0200 Subject: [PATCH 7/8] Fix warning in rle4 decoding --- src/bin/jp2/convertbmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index 1131a599..0678d9d3 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -572,7 +572,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN); for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) { - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } } else { /* absolute mode */ @@ -598,7 +598,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride if((j&1) == 0) { c1 = (OPJ_UINT8)getc(IN); } - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */ getc(IN); From f82d7f3a63a99997449b15390d0c3f2fc6159d9c Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 23 Sep 2015 21:17:06 +0200 Subject: [PATCH 8/8] Use buffer on stack to read TGA header Fixes a potential leak Fixes #601 --- src/bin/jp2/convert.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index a894a369..1ccb34f8 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -573,7 +573,7 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, unsigned int *width, unsigned int *height, int *flip_image) { int palette_size; - unsigned char *tga ; + unsigned char tga[TGA_HEADER_SIZE]; unsigned char id_len, /*cmap_type,*/ image_type; unsigned char pixel_depth, image_desc; unsigned short /*cmap_index,*/ cmap_len, cmap_entry_size; @@ -581,7 +581,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, if (!bits_per_pixel || !width || !height || !flip_image) return 0; - tga = (unsigned char*)malloc(18); if ( fread(tga, TGA_HEADER_SIZE, 1, fp) != 1 ) { @@ -605,8 +604,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, pixel_depth = (unsigned char)tga[16]; image_desc = (unsigned char)tga[17]; - free(tga); - *bits_per_pixel = (unsigned int)pixel_depth; *width = (unsigned int)image_w; *height = (unsigned int)image_h;