avformat/aviobuf: Check that avio_seek() target is non negative

Fixes out of array access

Suggested-by: Andrew Scherkus <scherkus@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit ed86dbd05d)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2014-12-14 17:26:11 +01:00
parent 9f993d2d4b
commit 1aedd7645a

View File

@@ -203,6 +203,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
return offset1; return offset1;
offset += offset1; offset += offset1;
} }
if (offset < 0)
return AVERROR(EINVAL);
offset1 = offset - pos; offset1 = offset - pos;
if (!s->must_flush && if (!s->must_flush &&
offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) { offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {