* [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet
@ 2023-06-19 16:00 Armstrong Huang
2023-06-20 15:05 ` Armstrong Huang
0 siblings, 1 reply; 2+ messages in thread
From: Armstrong Huang @ 2023-06-19 16:00 UTC (permalink / raw)
To: ffmpeg-devel
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 | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..9d2b0730f1 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1096,7 +1096,14 @@ 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 flv
tag body\n");
+ 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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet
2023-06-19 16:00 [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet Armstrong Huang
@ 2023-06-20 15:05 ` Armstrong Huang
0 siblings, 0 replies; 2+ messages in thread
From: Armstrong Huang @ 2023-06-20 15:05 UTC (permalink / raw)
To: ffmpeg-devel
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-20 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 16:00 [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet Armstrong Huang
2023-06-20 15:05 ` Armstrong Huang
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