From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 82D8D46116 for ; Sat, 6 May 2023 13:25:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0EA9B68C079; Sat, 6 May 2023 16:25:13 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B12FC68C0CF for ; Sat, 6 May 2023 16:25:06 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id F29B41BF206 for ; Sat, 6 May 2023 13:25:05 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 6 May 2023 15:25:03 +0200 Message-Id: <20230506132503.9524-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230506132503.9524-1-michael@niedermayer.cc> References: <20230506132503.9524-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avformat/mpeg: Fix filename extension check for subtitle file X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This fixes undefined behavior and other issues. No testcase, this was found by code review Signed-off-by: Michael Niedermayer --- 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-request@ffmpeg.org with subject "unsubscribe".