curl/0002-curl-7.21.2-c6b97a8.patch
2010-11-09 17:55:44 +01:00

109 lines
3.1 KiB
Diff

From 9d506521f3c22e94da5c80eebef2b9438073c75d Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
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
</protocol>
<file name="log/curl1036.out">
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
</protocol>
</verify>
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
</protocol>
</verify>
--
1.7.2.3