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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7210>
This commit is contained in:
Max Romanov 2024-07-08 11:29:08 +03:00 committed by GStreamer Marge Bot
parent c541cbef92
commit 09257b391c

View file

@ -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);