96 lines
2.9 KiB
Diff
96 lines
2.9 KiB
Diff
From 8b1c866e93749fd42d1908ec77a4f339343acbb2 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
|
|
Date: Mon, 30 Sep 2024 16:22:19 +0300
|
|
Subject: [PATCH] jpegdec: Directly error out on negotiation failures
|
|
|
|
Thanks to Antonio Morales for finding and reporting the issue.
|
|
|
|
Fixes GHSL-2024-247
|
|
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3862
|
|
|
|
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8052>
|
|
---
|
|
ext/jpeg/gstjpegdec.c | 22 +++++++++++++++++-----
|
|
1 file changed, 17 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c
|
|
index 5442168..3374e18 100644
|
|
--- a/ext/jpeg/gstjpegdec.c
|
|
+++ b/ext/jpeg/gstjpegdec.c
|
|
@@ -947,13 +947,14 @@ format_not_supported:
|
|
}
|
|
}
|
|
|
|
-static void
|
|
+static gboolean
|
|
gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|
gboolean interlaced)
|
|
{
|
|
GstVideoCodecState *outstate;
|
|
GstVideoInfo *info;
|
|
GstVideoFormat format;
|
|
+ gboolean res;
|
|
|
|
switch (clrspc) {
|
|
case JCS_RGB:
|
|
@@ -976,7 +977,7 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|
height == GST_VIDEO_INFO_HEIGHT (info) &&
|
|
format == GST_VIDEO_INFO_FORMAT (info)) {
|
|
gst_video_codec_state_unref (outstate);
|
|
- return;
|
|
+ return TRUE;
|
|
}
|
|
gst_video_codec_state_unref (outstate);
|
|
}
|
|
@@ -984,6 +985,8 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|
outstate =
|
|
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), format,
|
|
width, height, dec->input_state);
|
|
+ if (!outstate)
|
|
+ return FALSE;
|
|
|
|
switch (clrspc) {
|
|
case JCS_RGB:
|
|
@@ -1005,10 +1008,12 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|
|
|
gst_video_codec_state_unref (outstate);
|
|
|
|
- gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
|
|
+ res = gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
|
|
|
|
GST_DEBUG_OBJECT (dec, "max_v_samp_factor=%d", dec->cinfo.max_v_samp_factor);
|
|
GST_DEBUG_OBJECT (dec, "max_h_samp_factor=%d", dec->cinfo.max_h_samp_factor);
|
|
+
|
|
+ return res;
|
|
}
|
|
|
|
static GstFlowReturn
|
|
@@ -1274,8 +1279,9 @@ gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
|
|
num_fields = 1;
|
|
}
|
|
|
|
- gst_jpeg_dec_negotiate (dec, width, output_height,
|
|
- dec->cinfo.jpeg_color_space, num_fields == 2);
|
|
+ if (!gst_jpeg_dec_negotiate (dec, width, output_height,
|
|
+ dec->cinfo.jpeg_color_space, num_fields == 2))
|
|
+ goto negotiation_failed;
|
|
|
|
state = gst_video_decoder_get_output_state (bdec);
|
|
ret = gst_video_decoder_allocate_output_frame (bdec, frame);
|
|
@@ -1392,6 +1398,12 @@ need_more_data:
|
|
ret = GST_FLOW_OK;
|
|
goto exit;
|
|
}
|
|
+negotiation_failed:
|
|
+ {
|
|
+ GST_ELEMENT_ERROR (dec, CORE, NEGOTIATION, (NULL), ("failed to negotiate"));
|
|
+ ret = GST_FLOW_NOT_NEGOTIATED;
|
|
+ goto exit;
|
|
+ }
|
|
/* ERRORS */
|
|
decode_error:
|
|
{
|
|
--
|
|
2.33.0
|
|
|