Add a check for code 550 when requesting file size
---
libavformat/ftp.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 97ad80d..64a5250 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -391,13 +391,17 @@ static int ftp_file_size(FTPContext *s)
char command[CONTROL_BUFFER_SIZE];
char *res = NULL;
static const int size_codes[] = {213, 0};
+ int resp_code;
snprintf(command, sizeof(command), "SIZE %s\r\n", s->path);
- if (ftp_send_command(s, command, size_codes, &res) == 213 && res &&
strlen(res) > 4) {
+ resp_code = ftp_send_command(s, command, size_codes, &res);
+ if (resp_code == 213 && res && strlen(res) > 4) {
s->filesize = strtoll(&res[4], NULL, 10);
} else {
s->filesize = -1;
av_free(res);
+ if (resp_code == 550)
+ return AVERROR(ENOENT);
return AVERROR(EIO);
}
@@ -723,10 +727,13 @@ static int ftp_open(URLContext *h, const char
*url, int flags)
if ((err = ftp_connect(h, url)) < 0)
goto fail;
+ if ((err = ftp_file_size(s)) == AVERROR(ENOENT))
+ goto fail;
+
if (ftp_restart(s, 0) < 0) {
h->is_streamed = 1;
} else {
- if (ftp_file_size(s) < 0 && flags & AVIO_FLAG_READ)
+ if (err < 0 && flags & AVIO_FLAG_READ)
h->is_streamed = 1;
if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)
h->is_streamed = 1;
--
2.17.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".