Commit c8252171 authored by Lukasz Marek's avatar Lukasz Marek

lavf/ftp: always treat all response codes >= 500 as error

Signed-off-by: 's avatarLukasz Marek <lukasz.m.luki2@gmail.com>
parent a0358db3
......@@ -149,13 +149,17 @@ static int ftp_status(FTPContext *s, char **line, const int response_codes[])
}
if (!code_found) {
for (i = 0; response_codes[i]; ++i) {
if (err == response_codes[i]) {
code_found = 1;
result = err;
break;
if (err >= 500) {
code_found = 1;
result = err;
} else
for (i = 0; response_codes[i]; ++i) {
if (err == response_codes[i]) {
code_found = 1;
result = err;
break;
}
}
}
}
if (code_found) {
if (line)
......@@ -209,8 +213,8 @@ static int ftp_auth(FTPContext *s)
const char *user = NULL, *pass = NULL;
char *end = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE];
int err;
static const int user_codes[] = {331, 230, 500, 530, 0}; /* 500, 530 are incorrect codes */
static const int pass_codes[] = {230, 503, 530, 0}; /* 503, 530 are incorrect codes */
static const int user_codes[] = {331, 230, 0};
static const int pass_codes[] = {230, 0};
/* Authentication may be repeated, original string has to be saved */
av_strlcpy(credencials, s->credencials, sizeof(credencials));
......@@ -244,7 +248,7 @@ static int ftp_passive_mode_epsv(FTPContext *s)
int i;
static const char d = '|';
static const char *command = "EPSV\r\n";
static const int epsv_codes[] = {229, 500, 501, 0}; /* 500, 501 are incorrect codes */
static const int epsv_codes[] = {229, 0};
if (ftp_send_command(s, command, epsv_codes, &res) != 229 || !res)
goto fail;
......@@ -285,7 +289,7 @@ static int ftp_passive_mode(FTPContext *s)
char *res = NULL, *start = NULL, *end = NULL;
int i;
static const char *command = "PASV\r\n";
static const int pasv_codes[] = {227, 501, 0}; /* 501 is incorrect code */
static const int pasv_codes[] = {227, 0};
if (ftp_send_command(s, command, pasv_codes, &res) != 227 || !res)
goto fail;
......@@ -368,7 +372,7 @@ static int ftp_file_size(FTPContext *s)
{
char command[CONTROL_BUFFER_SIZE];
char *res = NULL;
static const int size_codes[] = {213, 501, 550, 0}; /* 501, 550 are incorrect codes */
static const int size_codes[] = {213, 0};
snprintf(command, sizeof(command), "SIZE %s\r\n", s->path);
if (ftp_send_command(s, command, size_codes, &res) == 213 && res) {
......@@ -386,7 +390,7 @@ static int ftp_file_size(FTPContext *s)
static int ftp_retrieve(FTPContext *s)
{
char command[CONTROL_BUFFER_SIZE];
static const int retr_codes[] = {150, 550, 554, 0}; /* 550, 554 are incorrect codes */
static const int retr_codes[] = {150, 0};
snprintf(command, sizeof(command), "RETR %s\r\n", s->path);
if (ftp_send_command(s, command, retr_codes, NULL) != 150)
......@@ -414,7 +418,7 @@ static int ftp_store(FTPContext *s)
static int ftp_type(FTPContext *s)
{
static const char *command = "TYPE I\r\n";
static const int type_codes[] = {200, 500, 504, 0}; /* 500, 504 are incorrect codes */
static const int type_codes[] = {200, 0};
if (ftp_send_command(s, command, type_codes, NULL) != 200)
return AVERROR(EIO);
......@@ -425,7 +429,7 @@ static int ftp_type(FTPContext *s)
static int ftp_restart(FTPContext *s, int64_t pos)
{
char command[CONTROL_BUFFER_SIZE];
static const int rest_codes[] = {350, 500, 501, 0}; /* 500, 501 are incorrect codes */
static const int rest_codes[] = {350, 0};
snprintf(command, sizeof(command), "REST %"PRId64"\r\n", pos);
if (ftp_send_command(s, command, rest_codes, NULL) != 350)
......@@ -438,8 +442,8 @@ static int ftp_features(FTPContext *s)
{
static const char *feat_command = "FEAT\r\n";
static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
static const int feat_codes[] = {211, 500, 502, 0}; /* 500, 502 are incorrect codes */
static const int opts_codes[] = {200, 451, 500, 502}; /* 500, 451, 502 are incorrect codes */
static const int feat_codes[] = {211, 0};
static const int opts_codes[] = {200, 451};
char *feat;
if (ftp_send_command(s, feat_command, feat_codes, &feat) == 211) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment