summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2024-02-18 17:02:25 +0100
committerEven Rouault <even.rouault@spatialys.com>2024-02-18 17:02:25 +0100
commit7bd884f8750892de4f50bf4642fcfbe7011c6bdf (patch)
treedd240146e716c57d6a20946f7b10ee43e7694073 /src
parent90312af28d34679e641ce7bd7e3e68a0db49555f (diff)
opj_decompress: fix off-by-one read heap-buffer-overflow in sycc420_to_rgb() when x0 and y0 are odd (CVE-2021-3575, fixes #1347)
Diffstat (limited to 'src')
-rw-r--r--src/bin/common/color.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/common/color.c b/src/bin/common/color.c
index 27f15f13..ae5d648d 100644
--- a/src/bin/common/color.c
+++ b/src/bin/common/color.c
@@ -358,7 +358,15 @@ static void sycc420_to_rgb(opj_image_t *img)
if (i < loopmaxh) {
size_t j;
- for (j = 0U; j < (maxw & ~(size_t)1U); j += 2U) {
+ if (offx > 0U) {
+ sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
+ ++y;
+ ++r;
+ ++g;
+ ++b;
+ }
+
+ for (j = 0U; j < (loopmaxw & ~(size_t)1U); j += 2U) {
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y;
@@ -375,7 +383,7 @@ static void sycc420_to_rgb(opj_image_t *img)
++cb;
++cr;
}
- if (j < maxw) {
+ if (j < loopmaxw) {
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
}
}