From 50b3cfa22176c90325b414aaf7ba7213e4464111 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 14 Dec 2013 21:55:03 +0100 Subject: demux_mkv: don't seek outside of the file when finding segments The end of the current segment will be the end of the file if there is no next segment. Normally, this didn't matter much, since UNIX files allow seeking past the end of the file. But when opening files from HTTP, this would print confusing error messages. So explicitly check for EOF before trying to read a segment. --- demux/demux_mkv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index f4f78bc70c..5f1e2a5c0a 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1788,7 +1788,10 @@ static int read_mkv_segment_header(demuxer_t *demuxer) mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] (skipping)\n"); if (len == EBML_UINT_INVALID) break; - if (!stream_seek(s, stream_tell(s) + len)) { + int64_t next = stream_tell(s) + len; + if (next >= s->end_pos) + return 0; + if (!stream_seek(s, next)) { mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Failed to seek in file\n"); return 0; } -- cgit v1.2.3