@@ -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);
}
This fixes undefined behavior and other issues. No testcase, this was found by code review Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/mpeg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)