From 57b5555c91a9792e3ac99102b3d1a5c44b45fdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 5 Mar 2010 22:35:21 +0000 Subject: 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. Originally committed as revision 22226 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/http.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'libavformat/http.c') diff --git a/libavformat/http.c b/libavformat/http.c index 0c07592039..da200213ce 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -71,11 +71,7 @@ static int http_open_cnx(URLContext *h) /* 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 @@ static int http_open_cnx(URLContext *h) 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; -- cgit v1.2.3