comparison 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
comparison
equal deleted inserted replaced
5755:dbc61b2840eb 5756:7c7fe75728dd
69 /* fill the dest addr */ 69 /* fill the dest addr */
70 redo: 70 redo:
71 /* needed in any case to build the host string */ 71 /* needed in any case to build the host string */
72 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, 72 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
73 path1, sizeof(path1), s->location); 73 path1, sizeof(path1), s->location);
74 if (port > 0) { 74 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
75 snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
76 } else {
77 av_strlcpy(hoststr, hostname, sizeof(hoststr));
78 }
79 75
80 if (use_proxy) { 76 if (use_proxy) {
81 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, 77 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
82 NULL, 0, proxy_path); 78 NULL, 0, proxy_path);
83 path = s->location; 79 path = s->location;
88 path = path1; 84 path = path1;
89 } 85 }
90 if (port < 0) 86 if (port < 0)
91 port = 80; 87 port = 80;
92 88
93 snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port); 89 ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
94 err = url_open(&hd, buf, URL_RDWR); 90 err = url_open(&hd, buf, URL_RDWR);
95 if (err < 0) 91 if (err < 0)
96 goto fail; 92 goto fail;
97 93
98 s->hd = hd; 94 s->hd = hd;