[PATCH] Do not keep authentication in URL on connection through a proxy
Clément Bœsch
ubitux at gmail.com
Thu Nov 18 21:27:03 CET 2010
---
stream/network.c | 2 +-
stream/url.c | 38 ++++++++++++++++++++++++++++++++++++++
stream/url.h | 1 +
3 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/stream/network.c b/stream/network.c
index 02ddcc8..74da18f 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -209,7 +209,7 @@ http_send_request( URL_t *url, off_t pos ) {
mp_msg(MSGT_NETWORK, MSGL_ERR, "Invalid URL '%s' to proxify\n", url->file+1);
goto err_out;
}
- http_set_uri( http_hdr, server_url->url );
+ http_set_uri( http_hdr, server_url->noauth_url );
} else {
server_url = url;
http_set_uri( http_hdr, server_url->file );
diff --git a/stream/url.c b/stream/url.c
index 0469de9..90f41f7 100644
--- a/stream/url.c
+++ b/stream/url.c
@@ -58,6 +58,33 @@ URL_t *url_redirect(URL_t **url, const char *redir) {
return res;
}
+#ifdef __GNUC__
+static void make_noauth_url(URL_t *url, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
+#endif
+
+static void make_noauth_url(URL_t *url, const char *fmt, ...)
+{
+ va_list va1, va2;
+ int len;
+
+ va_start(va1, fmt);
+ va_copy(va2, va1);
+ len = vsnprintf(NULL, 0, fmt, va1);
+ if (len < 0) {
+ url->noauth_url = NULL;
+ goto end;
+ }
+ len++;
+ url->noauth_url = malloc(len);
+ if (!url->noauth_url)
+ goto end;
+ vsnprintf(url->noauth_url, len, fmt, va2);
+
+end:
+ va_end(va1);
+ va_end(va2);
+}
+
URL_t*
url_new(const char* url) {
int pos1, pos2,v6addr = 0;
@@ -232,6 +259,17 @@ url_new(const char* url) {
strcpy(Curl->file, "/");
}
+ if (Curl->port)
+ make_noauth_url(Curl, "%s://%s:%d%s", Curl->protocol,
+ Curl->hostname, Curl->port, Curl->file);
+ else
+ make_noauth_url(Curl, "%s://%s%s", Curl->protocol,
+ Curl->hostname, Curl->file);
+ if (Curl->noauth_url == NULL) {
+ mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed);
+ goto err_out;
+ }
+
free(escfilename);
return Curl;
err_out:
diff --git a/stream/url.h b/stream/url.h
index fab81ec..c89d91a 100644
--- a/stream/url.h
+++ b/stream/url.h
@@ -27,6 +27,7 @@
typedef struct {
char *url;
+ char *noauth_url;
char *protocol;
char *hostname;
char *file;
--
1.7.3.2
--MiFvc8Vo6wRSORdP--
More information about the MPlayer-dev-eng
mailing list