From: Haris <memoryvestiges@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] #7107 [PATCH] Fix seeking beyond file duration by returning an error when metadata is incorrect Date: Sat, 1 Mar 2025 15:51:52 +0200 Message-ID: <CABtG4u5q_R-RZLs5+7rY2z_UoHm7mZCXP7xUER1+jwymhnJGGw@mail.gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 824 bytes --] Hi, If we try to extract audio from an .mp3 file starting from a point that is beyond its total duration with command: *./ffmpeg -ss 600 -i eye.mp3 -c:a libopus output.opus* We should hit this if statement in libavformat/seek.c: if (min_ts > ts || max_ts < ts) return -1; But if the file's metadata are corrupted then min_ts and max_ts will not be the correct ones. min_ts and max_ts take the values of the metadata durations of the file. By adding the following check, we make sure that we return an error even if the metadata is corrupted: if (ts > s->duration) { av_log(NULL, AV_LOG_ERROR, "Seek position (%d) is larger than file duration (%d). Exiting...\n", ts, s->duration); return AVERROR_INVALIDDATA; } This is my first patch submission. Please let me know if any modifications are needed. Thanks, bayesiandog [-- Attachment #2: 0001-Fix-seeking-beyond-file-duration-by-returning-an-err.patch --] [-- Type: text/x-patch, Size: 994 bytes --] From f586e036abd8a744ef8b650071e22d873e0cdacc Mon Sep 17 00:00:00 2001 From: bayesiandog <memoryvestiges@gmail.com> Date: Sat, 1 Mar 2025 15:45:42 +0200 Subject: [PATCH] Fix seeking beyond file duration by returning an error when metadata is incorrect --- libavformat/seek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/seek.c b/libavformat/seek.c index 9518f0f41c..90b374b332 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -668,8 +668,8 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int ret; if (ts > s->duration) { - av_log(NULL, AV_LOG_ERROR, "Seek position (%d) is larger than file duration (%d). Exiting...\n", ts, s->duration); - exit(1); + av_log(NULL, AV_LOG_ERROR, "Seek position (%lld) is larger than file duration (%lld). Check metadata...\n", ts, s->duration); + return AVERROR_INVALIDDATA; } if (min_ts > ts || max_ts < ts) -- 2.39.5 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
reply other threads:[~2025-03-01 13:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CABtG4u5q_R-RZLs5+7rY2z_UoHm7mZCXP7xUER1+jwymhnJGGw@mail.gmail.com \ --to=memoryvestiges@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git