summaryrefslogtreecommitdiff
path: root/libavcodec/exr.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>2015-12-13 23:37:25 +0100
committerLuca Barbato <lu_zero@gentoo.org>2015-12-16 22:22:06 +0100
commit5ea59b1f424f0efc7805d837e6fdb80561fb0f3a (patch)
tree866038c8f6d01f97a798efa550f67684c5113009 /libavcodec/exr.c
parent17776638c392d104975aba169e17b186490e1d5e (diff)
exr: fix out of bounds read in get_code
This macro unconditionally used out[-1], which causes an out of bounds read, if out is the very beginning of the buffer. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/exr.c')
-rw-r--r--libavcodec/exr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index cdcdd7cc6c..c1059f8931 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -459,7 +459,7 @@ static int huf_build_dec_table(const uint64_t *hcode, int im,
lc += 8; \
}
-#define get_code(po, rlc, c, lc, gb, out, oe) \
+#define get_code(po, rlc, c, lc, gb, out, oe, outb) \
{ \
if (po == rlc) { \
if (lc < 8) \
@@ -468,7 +468,7 @@ static int huf_build_dec_table(const uint64_t *hcode, int im,
\
cs = c >> lc; \
\
- if (out + cs > oe) \
+ if (out + cs > oe || out == outb) \
return AVERROR_INVALIDDATA; \
\
s = out[-1]; \
@@ -501,7 +501,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
if (pl.len) {
lc -= pl.len;
- get_code(pl.lit, rlc, c, lc, gb, out, oe);
+ get_code(pl.lit, rlc, c, lc, gb, out, oe, outb);
} else {
int j;
@@ -518,7 +518,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
if ((hcode[pl.p[j]] >> 6) ==
((c >> (lc - l)) & ((1LL << l) - 1))) {
lc -= l;
- get_code(pl.p[j], rlc, c, lc, gb, out, oe);
+ get_code(pl.p[j], rlc, c, lc, gb, out, oe, outb);
break;
}
}
@@ -539,7 +539,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
if (pl.len) {
lc -= pl.len;
- get_code(pl.lit, rlc, c, lc, gb, out, oe);
+ get_code(pl.lit, rlc, c, lc, gb, out, oe, outb);
} else {
return AVERROR_INVALIDDATA;
}