From 09257b391cfc40bf167ed3a532dea445e7cc7b71 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 8 Jul 2024 11:29:08 +0300 Subject: [PATCH] rtspconnection: Handle invalid argument properly In case when conn->input_stream is NULL and glib was built with "glib_checks" enabled, g_pollable_input_stream_read_nonblocking() returns -1, but does not set the "err". The call stack: read_bytes() -> fill_bytes() -> fill_raw_bytes() The return value -1 passed up to read_bytes() and incorrectly processed there after "error:" label. This changes the return value to EINVAL. Part-of: --- .../gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c b/subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c index dd39dc00ba..120ad4f73f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c @@ -1672,6 +1672,9 @@ read_bytes (GstRTSPConnection * conn, guint8 * buffer, guint * idx, guint size, if (G_UNLIKELY (*idx > size)) return GST_RTSP_ERROR; + if (G_UNLIKELY (!conn->input_stream)) + return GST_RTSP_EINVAL; + left = size - *idx; while (left) { @@ -1690,6 +1693,9 @@ error: if (G_UNLIKELY (r == 0)) return GST_RTSP_EEOF; + if (G_UNLIKELY (!err)) + return GST_RTSP_EINVAL; + GST_DEBUG ("%s", err->message); res = gst_rtsp_result_from_g_io_error (err, GST_RTSP_ESYS); g_clear_error (&err);