aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
authorPetr Doubek <doubek@vision.ee.ethz.ch>2004-08-12 00:09:32 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-08-12 00:09:32 +0000
commit6ba5cbc699e77cae66bb719354fa142114b64eab (patch)
tree4d0862ca409f9db2ad6f121e66fc40275557dfa4 /libavformat/tcp.c
parent1477ec35dd958bf2c1ec7b4221a3d571c5b61449 (diff)
downloadffmpeg-6ba5cbc699e77cae66bb719354fa142114b64eab.tar.gz
HTTP Authentication Patch by (Petr Doubek <doubek at vision dot ee dot ethz dot ch>)
tested and submitted by (Torsten Spindler <spindler at hbt dot arch dot ethz dot ch>) Originally committed as revision 3381 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 6475c1277b..8ec84ec4b6 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -63,25 +63,18 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
int fd_max, ret;
struct timeval tv;
socklen_t optlen;
+ char proto[1024],path[1024],tmp[1024]; // PETR: protocol and path strings
+
+ url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
+ &port, path, sizeof(path), uri); // PETR: use url_split
+ if (strcmp(proto,"tcp")) goto fail; // PETR: check protocol
+ if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); } // PETR: take only the part after '@' for tcp protocol
s = av_malloc(sizeof(TCPContext));
if (!s)
return -ENOMEM;
h->priv_data = s;
- p = uri;
- if (!strstart(p, "tcp://", &p))
- goto fail;
- q = hostname;
- while (*p != ':' && *p != '/' && *p != '\0') {
- if ((q - hostname) < sizeof(hostname) - 1)
- *q++ = *p;
- p++;
- }
- *q = '\0';
- if (*p != ':')
- goto fail;
- p++;
- port = strtoul(p, (char **)&p, 10);
+
if (port <= 0 || port >= 65536)
goto fail;