summaryrefslogtreecommitdiff
path: root/libavformat/cafdec.c
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2013-01-20 15:26:12 -0500
committerMichael Niedermayer <michaelni@gmx.at>2013-01-20 21:30:34 +0100
commit64b7e7dcaf21bd3c9f644446c59acdac6a95892f (patch)
tree7ef3be3733ed58eb8d76c00a5f69b1591b713e35 /libavformat/cafdec.c
parent3317414fc11a9a187b474141f4ac13f895c0b493 (diff)
downloadffmpeg-64b7e7dcaf21bd3c9f644446c59acdac6a95892f.tar.gz
cafdec: fix overflow checking in read_header()
Several compilers such as clang/icc/pathscale will optimize the check pos + size < pos (assuming size > 0) into false, since signed integer overflow is undefined behavior in C. This breaks overflow checking. Use a safe precondition check instead. Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/cafdec.c')
-rw-r--r--libavformat/cafdec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index f12226a8f5..337758ee12 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -300,7 +300,7 @@ static int read_header(AVFormatContext *s)
}
if (size > 0) {
- if (pos + size < pos)
+ if (pos > INT64_MAX - size)
return AVERROR_INVALIDDATA;
avio_skip(pb, FFMAX(0, pos + size - avio_tell(pb)));
}