webrtc, rtmp2: Warn if the user or password aren't escaped
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 31 Jul 2020 20:48:39 +0000 (02:18 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Mon, 3 Aug 2020 18:12:50 +0000 (18:12 +0000)
If the user/pass aren't escaped, the userinfo will be ambiguous and we
won't know where to split. We will accidentally get it right if the :
belongs in the password.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>

ext/webrtc/gstwebrtcice.c
gst/rtmp2/gstrtmp2locationhandler.c

index 9b2cc66..23a490b 100644 (file)
@@ -291,6 +291,12 @@ _parse_userinfo (const gchar * userinfo, gchar ** user, gchar ** pass)
     return;
   }
 
+  /* Check that the first occurence is also the last occurence */
+  if (colon != g_strrstr (userinfo, ":"))
+    GST_WARNING ("userinfo %s contains more than one ':', will assume that the "
+        "first ':' delineates user:pass. You should escape the user and pass "
+        "before adding to the URI.", userinfo);
+
   *user = g_strndup (userinfo, colon - userinfo);
   *pass = g_strdup (&colon[1]);
 }
index 7c79c79..d8e4367 100644 (file)
@@ -221,6 +221,11 @@ uri_handler_set_uri (GstURIHandler * handler, const gchar * string,
       goto out;
     }
 
+    if (g_strrstr (split[1], ":") != NULL)
+      GST_WARNING_OBJECT (self, "userinfo %s contains more than one ':', will "
+          "assume that the first ':' delineates user:pass. You should escape "
+          "the user and pass before adding to the URI.", userinfo);
+
     g_object_set (self, "username", split[0], "password", split[1], NULL);
     g_strfreev (split);
   }