diff options
author | Xi Wang <xi.wang@gmail.com> | 2013-03-15 06:59:22 -0400 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-03-15 13:21:15 +0100 |
commit | 22c27e1f4a6ff3d8d0409b30c8a9edb689ffdeaa (patch) | |
tree | aa3cccf746d55160aa2c8e1bbee00e6cdbca4958 | |
parent | 9d4355d90a6a8fc49f6ff05f98b86e37c262ac91 (diff) | |
download | ffmpeg-22c27e1f4a6ff3d8d0409b30c8a9edb689ffdeaa.tar.gz |
lzo: fix overflow checking in copy_backptr()
The check `src > dst' in the form `&c->out[-back] > c->out' invokes
pointer overflow, which is undefined behavior in C.
Remove the check. Also replace `&c->out[-back] < c->out_start' with
a safe form `c->out - c->out_start < back' to avoid overflow.
CC: libav-stable@libav.org
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit ca6c3f2c53be70aa3c38e8f1292809db89ea1ba6)
-rw-r--r-- | libavutil/lzo.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/libavutil/lzo.c b/libavutil/lzo.c index eff3cd2333..5c5ebc850a 100644 --- a/libavutil/lzo.c +++ b/libavutil/lzo.c @@ -110,9 +110,8 @@ static inline void copy(LZOContext *c, int cnt) */ static inline void copy_backptr(LZOContext *c, int back, int cnt) { - register const uint8_t *src = &c->out[-back]; register uint8_t *dst = c->out; - if (src < c->out_start || src > dst) { + if (dst - c->out_start < back) { c->error |= AV_LZO_INVALID_BACKPTR; return; } |