Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-12-14 01:17:09 +0300
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-12-20 17:40:01 +0300
commit79d75f1554de110d020a8035c86458a80dd7d773 (patch)
tree07d022b9964f656b892881cbddf811626478f106
parent105be66545ec3fa250e3a4e4792b097cec7f62a1 (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> (cherry picked from commit 90b99a81071d10e6b5efe86a4602d54d4f45bbcb) Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r--libavcodec/exr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 0e62f4e2d7..9088581b91 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -461,7 +461,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) \
@@ -470,7 +470,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]; \
@@ -503,7 +503,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;
@@ -520,7 +520,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;
}
}
@@ -541,7 +541,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;
}