From 19873dff0acf9e204066458e7ab465fba759142d Mon Sep 17 00:00:00 2001 From: Hajime Fujita Date: Sun, 31 Jan 2016 22:16:05 -0600 Subject: [PATCH] rtp: Introduce pa_rtsp_exec_ready() In the current RTSP implementation, there is a vulnerable window between the RTSP object creation and the URL initialization. If any RTSP command is issued during this period, it will lead to crash by assertion violation. This patch introduces pa_rtsp_exec_ready(), which returns if it is safe to issue RTSP commands. Reviewed-by: Anton Lundin --- src/modules/rtp/rtsp_client.c | 6 ++++++ src/modules/rtp/rtsp_client.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index 6e65860cb..198417ee5 100644 --- a/src/modules/rtp/rtsp_client.c +++ b/src/modules/rtp/rtsp_client.c @@ -389,6 +389,12 @@ void pa_rtsp_remove_header(pa_rtsp_client *c, const char *key) { pa_headerlist_remove(c->headers, key); } +bool pa_rtsp_exec_ready(const pa_rtsp_client *c) { + pa_assert(c); + + return c->url != NULL && c->ioline != NULL; +} + static int rtsp_exec(pa_rtsp_client *c, const char *cmd, const char *content_type, const char *content, int expect_response, diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h index 7e9978d49..abc60ee87 100644 --- a/src/modules/rtp/rtsp_client.h +++ b/src/modules/rtp/rtsp_client.h @@ -58,6 +58,8 @@ void pa_rtsp_set_url(pa_rtsp_client *c, const char *url); void pa_rtsp_add_header(pa_rtsp_client *c, const char *key, const char *value); void pa_rtsp_remove_header(pa_rtsp_client *c, const char *key); +bool pa_rtsp_exec_ready(const pa_rtsp_client *c); + int pa_rtsp_options(pa_rtsp_client *c); int pa_rtsp_announce(pa_rtsp_client *c, const char *sdp);