diff --git a/0002-curl-7.21.2-c6b97a8.patch b/0002-curl-7.21.2-c6b97a8.patch new file mode 100644 index 0000000..2ba40c0 --- /dev/null +++ b/0002-curl-7.21.2-c6b97a8.patch @@ -0,0 +1,108 @@ +From 9d506521f3c22e94da5c80eebef2b9438073c75d Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Thu, 4 Nov 2010 21:44:02 +0100 +Subject: [PATCH] ftp: close connection as soon as ABOR has been sent + +... and do not send ABOR unless really necessary. + +Bug: https://bugzilla.redhat.com/649347 +Reported by: Simon H. +--- + CHANGES | 8 ++++++++ + lib/ftp.c | 15 +++++++++++---- + tests/data/test1036 | 1 - + tests/data/test110 | 1 - + tests/data/test122 | 1 - + 5 files changed, 19 insertions(+), 7 deletions(-) + +diff --git a/CHANGES b/CHANGES +index 90ef831..a93216e 100644 +--- a/CHANGES ++++ b/CHANGES +@@ -6,6 +6,14 @@ + + Changelog + ++Kamil Dudka (4 Nov 2010) ++- ftp: close connection as soon as ABOR has been sent ++ ++ ... and do not send ABOR unless really necessary. ++ ++ Bug: https://bugzilla.redhat.com/649347 ++ Reported by: Simon H. ++ + Kamil Dudka (29 Oct 2010) + - ftp: prevent server from hanging on closed data connection + +diff --git a/lib/ftp.c b/lib/ftp.c +index b11be35..ddd1dcf 100644 +--- a/lib/ftp.c ++++ b/lib/ftp.c +@@ -3083,10 +3083,9 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, + #endif + + if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { +- if(!result && ftpc->dont_check) +- /* prevent some FTP servers (namely Pure-ftpd) from hanging if we close +- * the data channel before transferring all data */ +- result = Curl_pp_sendf(&ftpc->pp, "ABOR"); ++ if(!result && ftpc->dont_check && data->req.maxdownload > 0) ++ /* partial download completed */ ++ result = Curl_pp_sendf(pp, "ABOR"); + + if(conn->ssl[SECONDARYSOCKET].use) { + /* The secondary socket is using SSL so we must close down that part +@@ -3128,6 +3127,14 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, + if(result) + return result; + ++ if(ftpc->dont_check && data->req.maxdownload > 0) { ++ /* we have just sent ABOR and there is no reliable way to check if it was ++ * successful or not; we have to close the connection now */ ++ infof(data, "partial download completed, closing connection\n"); ++ conn->bits.close = TRUE; /* mark for closure */ ++ return result; ++ } ++ + if(!ftpc->dont_check) { + /* 226 Transfer complete, 250 Requested file action okay, completed. */ + if((ftpcode != 226) && (ftpcode != 250)) { +diff --git a/tests/data/test1036 b/tests/data/test1036 +index a31cb45..b8ebc4f 100644 +--- a/tests/data/test1036 ++++ b/tests/data/test1036 +@@ -50,7 +50,6 @@ TYPE I + SIZE 1036 + REST 20 + RETR 1036 +-ABOR + QUIT + + +diff --git a/tests/data/test110 b/tests/data/test110 +index 4a094e7..b63ba8a 100644 +--- a/tests/data/test110 ++++ b/tests/data/test110 +@@ -46,7 +46,6 @@ TYPE I + SIZE 110 + REST 20 + RETR 110 +-ABOR + QUIT + + +diff --git a/tests/data/test122 b/tests/data/test122 +index ac60672..fb1dd05 100644 +--- a/tests/data/test122 ++++ b/tests/data/test122 +@@ -39,7 +39,6 @@ EPSV + PASV + TYPE I + SIZE 122 +-ABOR + QUIT + + +-- +1.7.2.3 + diff --git a/0003-curl-7.21.2-bz650255.patch b/0003-curl-7.21.2-bz650255.patch new file mode 100644 index 0000000..f5cd244 --- /dev/null +++ b/0003-curl-7.21.2-bz650255.patch @@ -0,0 +1,29 @@ +From 1cd485edb996ab3c52e8501d452de00e0be3b092 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Tue, 9 Nov 2010 17:04:04 +0100 +Subject: [PATCH] curl: bz650255 + +--- + lib/ftp.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/lib/ftp.c b/lib/ftp.c +index d79878e..416e5ec 100644 +--- a/lib/ftp.c ++++ b/lib/ftp.c +@@ -425,6 +425,12 @@ static CURLcode ftp_readresp(curl_socket_t sockfd, + if(ftpcode) + *ftpcode = code; + ++ if(421 == code) ++ /* 421 means "Service not available, closing control connection." and FTP ++ * servers use it to signal that idle session timeout has been exceeded. ++ * If we ignored the response, it could end up hanging in some cases. */ ++ return CURLE_OPERATION_TIMEDOUT; ++ + return result; + } + +-- +1.7.2.3 + diff --git a/curl.spec b/curl.spec index 62e2d1a..92f07c3 100644 --- a/curl.spec +++ b/curl.spec @@ -1,7 +1,7 @@ Summary: A utility for getting files from remote servers (FTP, HTTP, and others) Name: curl Version: 7.21.2 -Release: 3%{?dist} +Release: 4%{?dist} License: MIT Group: Applications/Internet Source: http://curl.haxx.se/download/%{name}-%{version}.tar.lzma @@ -11,6 +11,13 @@ Source3: hide_selinux.c # ftp: prevent server from hanging on closed data connection (#643656) Patch1: 0001-curl-7.21.2-0c8e5f7.patch +# ftp: close connection as soon as ABOR has been sent (#649347) +Patch2: 0002-curl-7.21.2-c6b97a8.patch + +# return more appropriate error code in case FTP server session idle +# timeout has exceeded (#650255) +Patch3: 0003-curl-7.21.2-bz650255.patch + # patch making libcurl multilib ready Patch101: 0101-curl-7.21.1-multilib.patch @@ -108,6 +115,8 @@ done # upstream patches (already applied) %patch1 -p1 +%patch2 -p1 +%patch3 -p1 # Fedora patches %patch101 -p1 @@ -229,6 +238,11 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/aclocal/libcurl.m4 %changelog +* Tue Nov 09 2010 Kamil Dudka 7.21.2-4 +- prevent FTP client from hanging on unrecognized ABOR response (#649347) +- return more appropriate error code in case FTP server session idle + timeout has exceeded (#650255) + * Fri Oct 29 2010 Kamil Dudka 7.21.2-3 - prevent FTP server from hanging on closed data connection (#643656)