changeset 5869:754103ee76de libavformat

Reconstruct the RTSP URL, in order to remove the auth part from the URL sent to the server Don't modify the user-specified s->filename at all, keep all modifications locally and in rt->control_uri.
author mstorsjo
date Tue, 23 Mar 2010 07:55:15 +0000
parents 92daebc423f4
children b17b16b532ca
files rtsp.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/rtsp.c	Mon Mar 22 21:58:38 2010 +0000
+++ b/rtsp.c	Tue Mar 23 07:55:15 2010 +0000
@@ -1451,7 +1451,9 @@
     /* search for options */
     option_list = strchr(path, '?');
     if (option_list) {
-        filename = strchr(s->filename, '?');
+        /* Strip out the RTSP specific options, write out the rest of
+         * the options back into the same string. */
+        filename = option_list;
         while (option_list) {
             /* move the option pointer */
             option = ++option_list;
@@ -1467,8 +1469,11 @@
             } else if (!strcmp(option, "tcp")) {
                 lower_transport_mask = (1<< RTSP_LOWER_TRANSPORT_TCP);
             } else {
-                strcpy(++filename, option);
-                filename += strlen(option);
+                /* Write options back into the buffer, using memmove instead
+                 * of strcpy since the strings may overlap. */
+                int len = strlen(option);
+                memmove(++filename, option, len);
+                filename += len;
                 if (option_list) *filename = '&';
             }
         }
@@ -1505,10 +1510,13 @@
                     NULL, 0, NI_NUMERICHOST);
     }
 
+    /* Construct the URI used in request; this is similar to s->filename,
+     * but with authentication credentials removed and RTSP specific options
+     * stripped out. */
+    ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
+                host, port, "%s", path);
     /* request options supported by the server; this also detects server
      * type */
-    av_strlcpy(rt->control_uri, s->filename,
-               sizeof(rt->control_uri));
     for (rt->server_type = RTSP_SERVER_RTP;;) {
         snprintf(cmd, sizeof(cmd),
                  "OPTIONS %s RTSP/1.0\r\n", rt->control_uri);