Browse Source

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>
tags/n1.2
Xi Wang Michael Niedermayer 12 years ago
parent
commit
64b7e7dcaf
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      libavformat/cafdec.c

+ 1
- 1
libavformat/cafdec.c View File

@@ -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)));
}


Loading…
Cancel
Save