This fixes undefined behavior and other issues.
No testcase, this was found by code review

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
---
 libavformat/mpeg.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 781c3162d6..fdc808dc50 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -756,12 +756,17 @@ static int vobsub_read_header(AVFormatContext *s)
         }
 
         fname_len = strlen(vobsub->sub_name);
-        ext = vobsub->sub_name - 3 + fname_len;
-        if (fname_len < 4 || *(ext - 1) != '.') {
+        if (fname_len < 4) {
             av_log(s, AV_LOG_ERROR, "The input index filename is too short "
                    "to guess the associated .SUB file\n");
             return AVERROR_INVALIDDATA;
         }
+        ext = vobsub->sub_name + fname_len - 3;
+        if (*(ext - 1) != '.' || strchr(ext, '/')) {
+            av_log(s, AV_LOG_ERROR, "The input index filename needs to have a 
3 letter extension "
+                   "to guess the associated .SUB file\n");
+            return AVERROR_INVALIDDATA;
+        }
         memcpy(ext, !strncmp(ext, "IDX", 3) ? "SUB" : "sub", 3);
         av_log(s, AV_LOG_VERBOSE, "IDX/SUB: %s -> %s\n", s->url, 
vobsub->sub_name);
     }
-- 
2.17.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to