fixup! webrtc_private: Check prefix of STUN/TURN server URL 91/280091/4 accepted/tizen/unified/20220825.063620 submit/tizen/20220825.024408
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Aug 2022 12:41:06 +0000 (21:41 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Aug 2022 05:36:37 +0000 (14:36 +0900)
NULL and Empty string are allowed to be set as NULL.

Change-Id: Iff65bd17636c247daf1a6378e83b2d5fb001bfb0

src/webrtc.c
src/webrtc_private.c

index 4fd7f43bb84fcaeaf45c392b2dc2e9e802bb5b58..7703a0fe6884a3c41f38b82cbace2be59eef9db2 100644 (file)
@@ -963,11 +963,14 @@ int webrtc_set_stun_server(webrtc_h webrtc, const char *stun_server)
 
        g_free(_webrtc->stun_server_url);
 
-       /* FIXME: validate this url before setting */
-       _webrtc->stun_server_url = g_strdup(stun_server);
+       if (!stun_server || strlen(stun_server) == 0)
+               _webrtc->stun_server_url = NULL;
+       else
+               _webrtc->stun_server_url = g_strdup(stun_server);
+
        g_object_set(G_OBJECT(_webrtc->gst.webrtcbin), "stun-server", _webrtc->stun_server_url, NULL);
 
-       LOG_INFO("webrtc[%p] stun_server[%s]", webrtc, stun_server);
+       LOG_INFO("webrtc[%p] stun_server[%s]", webrtc, _webrtc->stun_server_url);
 
        return WEBRTC_ERROR_NONE;
 }
index 08f037765b841ea477992d2f99b0f0aa60b958ce..ed60b3d3cc06b17a6df23e7442d7507e8d0c0a30 100644 (file)
@@ -143,6 +143,9 @@ void _generate_dot(GstElement *pipeline, const gchar *name)
 
 bool _stun_url_has_valid_prefix(const char *url)
 {
+       if (!url || strlen(url) == 0)
+               return true;
+
        if (!g_str_has_prefix(url, "stun://")) {
                LOG_ERROR("STUN url[%s] must start with 'stun://'", url);
                return false;