Message ID | cc9853d1-3c0d-7835-cb98-85d8fd53331a@gmail.com |
---|---|
State | New |
Headers | show |
On Sat, Dec 28, 2019 at 04:11:54PM +0300, Fotyev V. wrote: > See attached > > On 2019-12-28 17:17, Michael Niedermayer wrote: > >On Sat, Dec 28, 2019 at 01:52:04PM +0300, Fotyev V. wrote: > >>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); > >patch is corrupted by newlines > > > >[...] > > > >thx > > > >_______________________________________________ > >ffmpeg-devel mailing list > >ffmpeg-devel@ffmpeg.org > >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > >To unsubscribe, visit link above, or email > >ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > ftp.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > c28f647f77a69ca7d24024277a89e52160dc642d 0001-libavformat-ftp-Exit-with-error-on-ftp_open-if-file-.patch > From 46108143e535962dd2d65398e7f794cbeb3e9cd7 Mon Sep 17 00:00:00 2001 > From: ftk <ftk@users.noreply.github.com> You may want to put your name in the author field, as this would be what ends in git as author thx [...]
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;