Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 7/8] avformat/flvdec: Fix error handling of parse_video_color_info
@ 2025-03-11  2:49 Zhao Zhili
  0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2025-03-11  2:49 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

From: Zhao Zhili <zhilizhao@tencent.com>

Some error should not be ignored.
---
 libavformat/flvdec.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index b4d2d7e2b8..b431dabffc 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1194,13 +1194,18 @@ static int flv_parse_video_color_info(AVFormatContext *s, AVStream *st, int64_t
 
     // first object needs to be "colorInfo" string
     type = avio_r8(ioc);
-    if (type != AMF_DATA_TYPE_STRING ||
-        amf_get_string(ioc, buffer, sizeof(buffer)) < 0)
-        return TYPE_UNKNOWN;
+    if (type != AMF_DATA_TYPE_STRING) {
+        av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo\n");
+        return 0;
+    }
 
-    if (strcmp(buffer, "colorInfo")) {
-        av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
-        return TYPE_UNKNOWN;
+    ret = amf_get_string(ioc, buffer, sizeof(buffer));
+    if (ret < 0)
+        return ret;
+
+    if (strcmp(buffer, "colorInfo") != 0) {
+        av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo type %s\n", buffer);
+        return 0;
     }
 
     flv->meta_color_info_flag = FLV_COLOR_INFO_FLAG_PARSING;
@@ -1481,8 +1486,9 @@ retry:
 
         if (enhanced_flv && (flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) {
             if (pkt_type == PacketTypeMetadata) {
-                int sret = flv_parse_video_color_info(s, st, next);
-                av_log(s, AV_LOG_DEBUG, "enhanced flv parse metadata ret %d and skip\n", sret);
+                ret = flv_parse_video_color_info(s, st, next);
+                if (ret < 0)
+                    goto leave;
             }
             goto skip;
         } else if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) {
-- 
2.46.0

_______________________________________________
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] only message in thread

only message in thread, other threads:[~2025-03-11  2:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-11  2:49 [FFmpeg-devel] [PATCH v2 7/8] avformat/flvdec: Fix error handling of parse_video_color_info Zhao Zhili

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