PR #24737 opened by Arielfoever URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24737 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24737.patch
In ftp_close, a server reponse (226 or 250 for OK) is required before close connection accorrding to RFC 959 in a uploading process. In the mean time, report any reponse except 226 and 250 to indicates there is an error in writing process from server. Closes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24601 Reported-by: filmars <[email protected]> Signed-off-by: Ariel Yu <[email protected]> # Summary of changes Add a wait process for server who is still writing. No timeout ( I assuem that all server will finish their job in a reasonable time) I haven't **fully tested** the patch yet. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From 4dd4e10632be4bb8d1dbf52586b690fbab8503a9 Mon Sep 17 00:00:00 2001 From: Ariel Yu <[email protected]> Date: Sun, 27 Sep 2026 17:59:16 +0800 Subject: [PATCH] libavformat/ftp: Add await for server reponse and then close connection. In ftp_close, a server reponse (226 or 250 for OK) is required before close connection accorrding to RFC 959 in a uploading process. In the mean time, report any reponse except 226 and 250 to indicates there is an error in writing process from server. Closes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24601 Reported-by: filmars <[email protected]> Signed-off-by: Ariel Yu <[email protected]> --- libavformat/ftp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libavformat/ftp.c b/libavformat/ftp.c index 3865177f99..bb28138c95 100644 --- a/libavformat/ftp.c +++ b/libavformat/ftp.c @@ -922,6 +922,27 @@ static int ftp_close(URLContext *h) ff_dlog(h, "ftp protocol close\n"); + /* Await server finish its writing */ + if (s->state == UPLOADING) { + static const int retr_codes[] = {226, 250, 425, 426, 451, 0}; + /* Close data connnection first*/ + ftp_close_data_connection(s); + if (s->conn_control) { + char *response = NULL; + /* Wait server 226 or 250 response. + It means the server finish uploading process*/ + int status = ftp_status(s, &response, retr_codes); + /*226=Transfer complete, 250=Requested file action okay, completed + others means some kind of error*/ + if (status != 226 && status != 250) + av_log(h, AV_LOG_WARNING, + "FTP upload completion status %d: %s\n", status, + response ? response : "?"); + av_freep(&response); + } + } + + /* After a 226 or 250 revieved, close control connection safely. */ ftp_close_both_connections(s); av_freep(&s->user); av_freep(&s->password); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
