diff http.c @ 5756:7c7fe75728dd libavformat

Use ff_url_join for assembling URLs, instead of snprintf This ensures proper escaping of numerical IPv6 addresses. The RTSP (de)muxer needs its own network initialization, since it isn't a protocol and url_open hasn't been called yet.
author mstorsjo
date Fri, 05 Mar 2010 22:35:21 +0000
parents fc48f8bfbf2e
children 7a123cc24a81
line wrap: on
line diff
--- a/http.c	Fri Mar 05 22:31:45 2010 +0000
+++ b/http.c	Fri Mar 05 22:35:21 2010 +0000
@@ -71,11 +71,7 @@
     /* needed in any case to build the host string */
     url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
               path1, sizeof(path1), s->location);
-    if (port > 0) {
-        snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
-    } else {
-        av_strlcpy(hoststr, hostname, sizeof(hoststr));
-    }
+    ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
 
     if (use_proxy) {
         url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
@@ -90,7 +86,7 @@
     if (port < 0)
         port = 80;
 
-    snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port);
+    ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
     err = url_open(&hd, buf, URL_RDWR);
     if (err < 0)
         goto fail;