From: Armstrong Huang <armstrong@sweelia.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet
Date: Tue, 20 Jun 2023 15:05:19 +0000
Message-ID: <20230620150519.15768-1-armstrong@sweelia.com> (raw)
In-Reply-To: <30247c6c-5fe6-8131-d4e9-b6388846437d@sweelia.com>
In most cases, flv_read_metabody reads pass the beginning of the meta_pos.
If the beginning of the meta_pos had been flushed from the IO buffer,
we would not be able to seek to the right position (for a nonseekable stream).
Is better to check the seek result and skip the current flv body if necessary,
than to silently try to read from a
desynchronized stream that will only be interpreted as garbage.
Signed-off-by: Armstrong Huang <armstrong@sweelia.com>
---
libavformat/flvdec.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..21ff73a1aa 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1096,7 +1096,18 @@ retry:
} else if (type == TYPE_UNKNOWN) {
stream_type = FLV_STREAM_TYPE_DATA;
}
- avio_seek(s->pb, meta_pos, SEEK_SET);
+ if (avio_seek(s->pb, meta_pos, SEEK_SET) != meta_pos) {
+ /**
+ * This can happen after flv_read_metabody
+ * above, on a non-seekable input, and the
+ * preceding data has been flushed out from
+ * the IO buffer.
+ */
+ av_log(s, AV_LOG_ERROR,
+ "Unable to seek back to the meta_pos: %ld\n",
+ meta_pos);
+ goto skip;
+ }
}
} else {
av_log(s, AV_LOG_DEBUG,
--
2.20.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".
prev parent reply other threads:[~2023-06-20 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 16:00 Armstrong Huang
2023-06-20 15:05 ` Armstrong Huang [this message]
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=20230620150519.15768-1-armstrong@sweelia.com \
--to=armstrong@sweelia.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