opj_compress: reorder checks related to code block dimensions, to avoid potential int overflow
This commit is contained in:
parent
0a25dceca7
commit
aa7198146b
|
@ -907,8 +907,9 @@ static int parse_cmdline_encoder(int argc, char **argv,
|
||||||
case 'b': { /* code-block dimension */
|
case 'b': { /* code-block dimension */
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init > 1024 || cblockw_init < 4 ||
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
cblockh_init > 1024 || cblockh_init < 4 ||
|
||||||
|
cblockw_init * cblockh_init > 4096) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
|
"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
|
||||||
" * width*height<=4096\n * 4<=width,height<= 1024\n\n");
|
" * width*height<=4096\n * 4<=width,height<= 1024\n\n");
|
||||||
|
|
Loading…
Reference in New Issue