From b91de7acd0671b2aa24832fb3b0cc061bba54228 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 6 Jul 2020 20:52:29 +0100 Subject: [PATCH 1/5] fix_1236_0.27 --- src/jp2image.cpp | 1 + test/data/icc-test.out | 112 +++++++++++++++++++++++++++++++++++++++++ test/icc-test.sh | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 0de088d6..c5be886c 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -693,6 +693,7 @@ static void boxes_check(size_t b,size_t m) ::memcpy(output.pData_+outlen+sizeof(newBox)+psize,iccProfile_.pData_,iccProfile_.size_); newlen = psize + iccProfile_.size_; } + newlen += sizeof(newBox); } else { ::memcpy(output.pData_+outlen,boxBuf.pData_+inlen,subBox.length); } diff --git a/test/data/icc-test.out b/test/data/icc-test.out index 54b9c2e9..14837a94 100644 --- a/test/data/icc-test.out +++ b/test/data/icc-test.out @@ -729,3 +729,115 @@ STRUCTURE OF JPEG FILE: ReaganLargeJpg.jpg 50b9125494306a6fc1b7c4f2a1a8d49d 45ed3c125cc6041b37b44ee4cb881cd8 45ed3c125cc6041b37b44ee4cb881cd8 +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3155 | sub:colr | ......HLino....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:3144 + 3217 | 0 | jp2c | +Exiv2 exception in modify action for file Reagan2.jp2: +Setting Image comment in JP2 images is not supported +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3155 | sub:colr | ......HLino....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:3144 + 3217 | 0 | jp2c | + +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in insert action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in extract action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in modify action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in erase action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in insert action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in extract action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in modify action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +Exiv2 exception in erase action for file Reagan2.jp2: +corrupted image metadata +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 +Exiv2 exception in print action for file Reagan2.jp2: +corrupted image metadata +1d3fda2edb4a89ab60a23c5f7c7d81dd +1d3fda2edb4a89ab60a23c5f7c7d81dd +19cf659cbc809b7c9035e026b6b6d618 +50b9125494306a6fc1b7c4f2a1a8d49d +19cf659cbc809b7c9035e026b6b6d618 +45ed3c125cc6041b37b44ee4cb881cd8 diff --git a/test/icc-test.sh b/test/icc-test.sh index f2492127..a098a09a 100755 --- a/test/icc-test.sh +++ b/test/icc-test.sh @@ -16,7 +16,7 @@ test1120() # --comment and -dc clobbered by writing ICC/JPG num=1074 # ICC Profile Support printf "ICC " >&3 - for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg # 1272 ReaganLargeTiff.tiff + for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg Reagan2.jp2 # 1272 ReaganLargeTiff.tiff do format=$(echo $filename|cut -d. -f 2) stub=$( echo $filename|cut -d. -f 1) From a7ba3d3d7d643ad77e80aeec4c71659d26a6b98b Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 6 Jul 2020 21:08:42 +0100 Subject: [PATCH 2/5] Reverting changes to test/icc-test.sh for investigation. --- test/data/icc-test.out | 112 ----------------------------------------- test/icc-test.sh | 2 +- 2 files changed, 1 insertion(+), 113 deletions(-) diff --git a/test/data/icc-test.out b/test/data/icc-test.out index 14837a94..54b9c2e9 100644 --- a/test/data/icc-test.out +++ b/test/data/icc-test.out @@ -729,115 +729,3 @@ STRUCTURE OF JPEG FILE: ReaganLargeJpg.jpg 50b9125494306a6fc1b7c4f2a1a8d49d 45ed3c125cc6041b37b44ee4cb881cd8 45ed3c125cc6041b37b44ee4cb881cd8 -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3155 | sub:colr | ......HLino....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:3144 - 3217 | 0 | jp2c | -Exiv2 exception in modify action for file Reagan2.jp2: -Setting Image comment in JP2 images is not supported -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3155 | sub:colr | ......HLino....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:3144 - 3217 | 0 | jp2c | - -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in insert action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in extract action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in modify action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in erase action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in insert action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in extract action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in modify action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -Exiv2 exception in erase action for file Reagan2.jp2: -corrupted image metadata -STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 - address | length | box | data - 0 | 12 | jP | - 12 | 20 | ftyp | - 32 | 3185 | jp2h | - 40 | 22 | sub:ihdr | ............. - 62 | 3147 | sub:colr | .x0...HLino....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:3144 -Exiv2 exception in print action for file Reagan2.jp2: -corrupted image metadata -1d3fda2edb4a89ab60a23c5f7c7d81dd -1d3fda2edb4a89ab60a23c5f7c7d81dd -19cf659cbc809b7c9035e026b6b6d618 -50b9125494306a6fc1b7c4f2a1a8d49d -19cf659cbc809b7c9035e026b6b6d618 -45ed3c125cc6041b37b44ee4cb881cd8 diff --git a/test/icc-test.sh b/test/icc-test.sh index a098a09a..f2492127 100755 --- a/test/icc-test.sh +++ b/test/icc-test.sh @@ -16,7 +16,7 @@ test1120() # --comment and -dc clobbered by writing ICC/JPG num=1074 # ICC Profile Support printf "ICC " >&3 - for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg Reagan2.jp2 # 1272 ReaganLargeTiff.tiff + for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg # 1272 ReaganLargeTiff.tiff do format=$(echo $filename|cut -d. -f 2) stub=$( echo $filename|cut -d. -f 1) From 181dd4738557eec0751f38c8be75c1f6c91a1e35 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Tue, 7 Jul 2020 18:56:18 +0100 Subject: [PATCH 3/5] Fix correctly this time and tested with the user files. Test suite updated to use Reagan2.jp2 --- src/jp2image.cpp | 7 +++---- test/data/icc-test.out | 30 ++++++++++++++++++++++++++++++ test/icc-test.sh | 14 ++++++++------ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/jp2image.cpp b/src/jp2image.cpp index c5be886c..4a69fd8b 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -678,22 +678,21 @@ static void boxes_check(size_t b,size_t m) if ( ! iccProfileDefined() ) { const char* pad = "\x01\x00\x00\x00\x00\x00\x10\x00\x00\x05\x1cuuid"; uint32_t psize = 15; + newlen = sizeof(newBox) + psize ; ul2Data((byte*)&newBox.length,psize ,bigEndian); ul2Data((byte*)&newBox.type ,newBox.type,bigEndian); ::memcpy(output.pData_+outlen ,&newBox ,sizeof(newBox)); ::memcpy(output.pData_+outlen+sizeof(newBox) ,pad ,psize ); - newlen = psize ; } else { const char* pad = "\0x02\x00\x00"; uint32_t psize = 3; - ul2Data((byte*)&newBox.length,psize+iccProfile_.size_,bigEndian); + newlen = sizeof(newBox) + psize + iccProfile_.size_; + ul2Data((byte*)&newBox.length,newlen,bigEndian); ul2Data((byte*)&newBox.type,newBox.type,bigEndian); ::memcpy(output.pData_+outlen ,&newBox ,sizeof(newBox) ); ::memcpy(output.pData_+outlen+sizeof(newBox) , pad ,psize ); ::memcpy(output.pData_+outlen+sizeof(newBox)+psize,iccProfile_.pData_,iccProfile_.size_); - newlen = psize + iccProfile_.size_; } - newlen += sizeof(newBox); } else { ::memcpy(output.pData_+outlen,boxBuf.pData_+inlen,subBox.length); } diff --git a/test/data/icc-test.out b/test/data/icc-test.out index 54b9c2e9..84dffff9 100644 --- a/test/data/icc-test.out +++ b/test/data/icc-test.out @@ -729,3 +729,33 @@ STRUCTURE OF JPEG FILE: ReaganLargeJpg.jpg 50b9125494306a6fc1b7c4f2a1a8d49d 45ed3c125cc6041b37b44ee4cb881cd8 45ed3c125cc6041b37b44ee4cb881cd8 +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 3185 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 3155 | sub:colr | ......HLino....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:3144 + 3217 | 0 | jp2c | +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 1613641 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 1613611 | sub:colr | .x0... APPL....prtrRGB Lab .. | pad: 0 120 48 | iccLength:1613600 + 1613673 | 0 | jp2c | +STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 + address | length | box | data + 0 | 12 | jP | + 12 | 20 | ftyp | + 32 | 601 | jp2h | + 40 | 22 | sub:ihdr | ............. + 62 | 571 | sub:colr | .x0...0ADBE....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:560 + 633 | 0 | jp2c | +1d3fda2edb4a89ab60a23c5f7c7d81dd +1d3fda2edb4a89ab60a23c5f7c7d81dd +50b9125494306a6fc1b7c4f2a1a8d49d +50b9125494306a6fc1b7c4f2a1a8d49d +45ed3c125cc6041b37b44ee4cb881cd8 +45ed3c125cc6041b37b44ee4cb881cd8 diff --git a/test/icc-test.sh b/test/icc-test.sh index f2492127..45899b18 100755 --- a/test/icc-test.sh +++ b/test/icc-test.sh @@ -5,18 +5,20 @@ source ./functions.source test1120() # --comment and -dc clobbered by writing ICC/JPG { - runTest exiv2 --comment abcdefg $filename - runTest exiv2 -pS $filename - runTest exiv2 -pc $filename - runTest exiv2 -dc $filename - runTest exiv2 -pS $filename + if [ "$filename" != "Reagan2.jp2" ]; then + runTest exiv2 --comment abcdefg $filename + runTest exiv2 -pS $filename + runTest exiv2 -pc $filename + runTest exiv2 -dc $filename + runTest exiv2 -pS $filename + fi } ( cd "$testdir" num=1074 # ICC Profile Support printf "ICC " >&3 - for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg # 1272 ReaganLargeTiff.tiff + for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg Reagan2.jp2 # 1272 ReaganLargeTiff.tiff do format=$(echo $filename|cut -d. -f 2) stub=$( echo $filename|cut -d. -f 1) From 22ed9b157bd6f3b1233c62b8625e6e93bf56f512 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Wed, 8 Jul 2020 13:51:51 +0100 Subject: [PATCH 4/5] Fixed typo declaration of pad when writing ICC profile. --- src/jp2image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 4a69fd8b..e6dae63b 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -684,7 +684,7 @@ static void boxes_check(size_t b,size_t m) ::memcpy(output.pData_+outlen ,&newBox ,sizeof(newBox)); ::memcpy(output.pData_+outlen+sizeof(newBox) ,pad ,psize ); } else { - const char* pad = "\0x02\x00\x00"; + const char* pad = "\x02\x00\x00"; uint32_t psize = 3; newlen = sizeof(newBox) + psize + iccProfile_.size_; ul2Data((byte*)&newBox.length,newlen,bigEndian); From 25726577715abf720540ca6717db72804fd717f0 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Wed, 8 Jul 2020 16:10:03 +0100 Subject: [PATCH 5/5] Update icc-test.out --- test/data/icc-test.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data/icc-test.out b/test/data/icc-test.out index 84dffff9..b495b2f3 100644 --- a/test/data/icc-test.out +++ b/test/data/icc-test.out @@ -743,7 +743,7 @@ STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 12 | 20 | ftyp | 32 | 1613641 | jp2h | 40 | 22 | sub:ihdr | ............. - 62 | 1613611 | sub:colr | .x0... APPL....prtrRGB Lab .. | pad: 0 120 48 | iccLength:1613600 + 62 | 1613611 | sub:colr | ...... APPL....prtrRGB Lab .. | pad: 2 0 0 | iccLength:1613600 1613673 | 0 | jp2c | STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 address | length | box | data @@ -751,7 +751,7 @@ STRUCTURE OF JPEG2000 FILE: Reagan2.jp2 12 | 20 | ftyp | 32 | 601 | jp2h | 40 | 22 | sub:ihdr | ............. - 62 | 571 | sub:colr | .x0...0ADBE....mntrRGB XYZ .. | pad: 0 120 48 | iccLength:560 + 62 | 571 | sub:colr | ......0ADBE....mntrRGB XYZ .. | pad: 2 0 0 | iccLength:560 633 | 0 | jp2c | 1d3fda2edb4a89ab60a23c5f7c7d81dd 1d3fda2edb4a89ab60a23c5f7c7d81dd