[JPWL] opj_compress: reorder checks related to code block dimensions to avoid potent...
authorYoung_X <YangX92@hotmail.com>
Fri, 23 Nov 2018 09:12:06 +0000 (17:12 +0800)
committerYoung Xiao <YangX92@hotmail.com>
Wed, 28 Nov 2018 06:39:14 +0000 (14:39 +0800)
Signed-off-by: Young_X <YangX92@hotmail.com>
src/bin/jpwl/opj_jpwl_compress.c

index 28f0670c0daf7fe9d020413b590c354ff3c12a07..c17486a0b59182ac0a8b9bc3c3dacbe3adb65716 100644 (file)
@@ -952,8 +952,9 @@ static int parse_cmdline_encoder(int argc, char **argv,
         case 'b': {         /* code-block dimension */
             int cblockw_init = 0, cblockh_init = 0;
             sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
-            if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
-                    || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
+            if (cblockw_init > 1024 || cblockw_init < 4 ||
+                    cblockh_init > 1024 || cblockh_init < 4 ||
+                    cblockw_init * cblockh_init > 4096) {
                 fprintf(stderr,
                         "!! Size of code_block error (option -b) !!\n\nRestriction :\n"
                         "    * width*height<=4096\n    * 4<=width,height<= 1024\n\n");