From dbec5ff0bcd65709f65e1d651853fedc39fb00a1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 28 Mar 2014 09:15:09 -0700 Subject: [PATCH] Fix out-of-bounds read when looking for subtitles in a matroska file with no subtitles --- src/mkv_wrap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mkv_wrap.cpp b/src/mkv_wrap.cpp index 05b1051a6..835762f1e 100644 --- a/src/mkv_wrap.cpp +++ b/src/mkv_wrap.cpp @@ -67,6 +67,10 @@ struct MkvStdIO final : InputStream { if (pos == self->file.size()) return 0; + auto remaining = self->file.size() - pos; + if (remaining < INT_MAX) + count = std::min(static_cast(remaining), count); + try { memcpy(buffer, self->file.read(pos, count), count); }