summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-14 21:55:03 +0100
committerwm4 <wm4@nowhere>2013-12-14 21:55:03 +0100
commit50b3cfa22176c90325b414aaf7ba7213e4464111 (patch)
tree3f429248f5b9accc98564c40dbb58dba3e4c55f7
parent2f49fbff93d76950c441daef76afb3adb9078429 (diff)
downloadmpv-50b3cfa22176c90325b414aaf7ba7213e4464111.tar.bz2
mpv-50b3cfa22176c90325b414aaf7ba7213e4464111.tar.xz
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.
-rw-r--r--demux/demux_mkv.c5
1 files changed, 4 insertions, 1 deletions
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;
}