summaryrefslogtreecommitdiff
path: root/tests/test_tile_encoder.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2016-09-21 21:15:25 +0200
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2016-09-22 08:16:13 +0200
commit7a5fb35b8d08686b57937d7584414c0594ef8b98 (patch)
tree150c5b5c693435063c227db36bb5059fb4731a1c /tests/test_tile_encoder.c
parent39f9934a70f5f01ddb7adc70801e981efb146f05 (diff)
Fix some issues reported by Coverity Scan (#846)
* test_tile_decoder: Fix potential buffer overflow (coverity) CID 1190155 (#1 of 1): Unbounded source buffer (STRING_SIZE) Using a pointer instead of buffer of fixed size avoids the limit for the length of the input file name. Signed-off-by: Stefan Weil <sw@weilnetz.de> * test_tile_encoder: Fix potential buffer overflow (coverity) CID 1190154 (#1 of 1): Unbounded source buffer (STRING_SIZE) Using a pointer instead of buffer of fixed size avoids the limit for the length of the output file name. This implies that the length can exceed 255, so the data type for variable len had to be fixed, too. Signed-off-by: Stefan Weil <sw@weilnetz.de> * openjpip: Initialize data before returning it This fixes an error reported by Coverity: CID 1190143 (#1 of 1): Uninitialized scalar variable (UNINIT) Signed-off-by: Stefan Weil <sw@weilnetz.de>
Diffstat (limited to 'tests/test_tile_encoder.c')
-rw-r--r--tests/test_tile_encoder.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_tile_encoder.c b/tests/test_tile_encoder.c
index d01a7e52..bd3fe351 100644
--- a/tests/test_tile_encoder.c
+++ b/tests/test_tile_encoder.c
@@ -69,7 +69,7 @@ int main (int argc, char *argv[])
opj_stream_t * l_stream;
OPJ_UINT32 l_nb_tiles;
OPJ_UINT32 l_data_size;
- unsigned char len;
+ size_t len;
#ifdef USING_MCT
const OPJ_FLOAT32 l_mct [] =
@@ -96,7 +96,7 @@ int main (int argc, char *argv[])
int tile_height;
int comp_prec;
int irreversible;
- char output_file[64];
+ const char *output_file;
/* should be test_tile_encoder 3 2000 2000 1000 1000 8 tte1.j2k */
if( argc == 9 )
@@ -108,7 +108,7 @@ int main (int argc, char *argv[])
tile_height = atoi( argv[5] );
comp_prec = atoi( argv[6] );
irreversible = atoi( argv[7] );
- strcpy(output_file, argv[8] );
+ output_file = argv[8];
}
else
{
@@ -119,7 +119,7 @@ int main (int argc, char *argv[])
tile_height = 1000;
comp_prec = 8;
irreversible = 1;
- strcpy(output_file, "test.j2k" );
+ output_file = "test.j2k";
}
if( num_comps > NUM_COMPS_MAX )
{
@@ -228,7 +228,7 @@ int main (int argc, char *argv[])
}
/* should we do j2k or jp2 ?*/
- len = (unsigned char)strlen( output_file );
+ len = strlen( output_file );
if( strcmp( output_file + len - 4, ".jp2" ) == 0 )
{
l_codec = opj_create_compress(OPJ_CODEC_JP2);