diff options
author | Marton Balint <cus@passwd.hu> | 2020-02-06 00:11:05 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2020-02-15 18:41:36 +0100 |
commit | f204a38e08f937f6204bb21a3d95a23089679fe0 (patch) | |
tree | f13cc0befa55d21a991b24815aa1ed4f5d51821e /libavformat/ftp.c | |
parent | 3004ef1b1b1bcd6bec4ad3509662ab1a4b644149 (diff) | |
download | ffmpeg-f204a38e08f937f6204bb21a3d95a23089679fe0.tar.gz |
avformat/ftp: add support for escaped credentials
Properly fixes ticket #7816.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/ftp.c')
-rw-r--r-- | libavformat/ftp.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/libavformat/ftp.c b/libavformat/ftp.c index 97ad80de0b..860dd7d8dc 100644 --- a/libavformat/ftp.c +++ b/libavformat/ftp.c @@ -24,6 +24,7 @@ #include "avformat.h" #include "internal.h" #include "url.h" +#include "urldecode.h" #include "libavutil/opt.h" #include "libavutil/bprint.h" @@ -658,7 +659,7 @@ static int ftp_connect(URLContext *h, const char *url) { char proto[10], path[MAX_URL_SIZE], credentials[MAX_URL_SIZE], hostname[MAX_URL_SIZE]; const char *tok_user = NULL, *tok_pass = NULL; - char *end = NULL, *newpath = NULL; + char *newpath = NULL; int err; FTPContext *s = h->priv_data; @@ -675,21 +676,28 @@ static int ftp_connect(URLContext *h, const char *url) path, sizeof(path), url); - tok_user = av_strtok(credentials, ":", &end); - tok_pass = av_strtok(end, ":", &end); - if (!tok_user) { + if (!*credentials) { if (!s->option_user) { tok_user = "anonymous"; tok_pass = av_x_if_null(s->anonymous_password, "nopassword"); } else { tok_user = s->option_user; + tok_pass = s->option_password; } + s->user = av_strdup(tok_user); + s->password = av_strdup(tok_pass); + } else { + char *pass = strchr(credentials, ':'); + if (pass) { + *pass++ = '\0'; + tok_pass = pass; + s->password = ff_urldecode(pass, 0); + } else { + tok_pass = s->option_password; + s->password = av_strdup(tok_pass); + } + s->user = ff_urldecode(credentials, 0); } - if (!tok_pass) { - tok_pass = s->option_password; - } - s->user = av_strdup(tok_user); - s->password = av_strdup(tok_pass); s->hostname = av_strdup(hostname); if (!s->hostname || !s->user || (tok_pass && !s->password)) { return AVERROR(ENOMEM); |