From 586fe4ea4bbc97283cc1db263e0e9d21c61228e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 16 Jan 2015 20:04:01 +0100 Subject: [PATCH] rtsp-client: Drop trailing \0 of RTSP DATA messages We add a trailing \0 in GstRTSPConnection to make parsing of string message bodies easier (e.g. the SDP from DESCRIBE) but for actual data this means we have to drop it or otherwise create invalid data. --- gst/rtsp-server/rtsp-client.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index 4099b78..faff8b1 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -2601,9 +2601,14 @@ handle_data (GstRTSPClient * client, GstRTSPMessage * message) if (res != GST_RTSP_OK) return; + gst_rtsp_message_get_body (message, &data, &size); + if (size < 2) + goto invalid_length; + gst_rtsp_message_steal_body (message, &data, &size); - buffer = gst_buffer_new_wrapped (data, size); + /* Strip trailing \0 */ + buffer = gst_buffer_new_wrapped (data, size - 1); trans = g_hash_table_lookup (priv->transports, GINT_TO_POINTER ((gint) channel)); @@ -2613,6 +2618,11 @@ handle_data (GstRTSPClient * client, GstRTSPMessage * message) } else { gst_buffer_unref (buffer); } +invalid_length: + { + GST_DEBUG ("client %p: Short message received, ignoring", client); + return; + } } /** -- 2.7.4