[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 189/411: ftp: make a 552 response return CURLE_REMOTE_DISK_FULL
From: |
gnunet |
Subject: |
[gnurl] 189/411: ftp: make a 552 response return CURLE_REMOTE_DISK_FULL |
Date: |
Wed, 13 Jan 2021 01:20:04 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 4a4c7245998af59dbc16f267fd5f000f2950ba4f
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Fri Sep 25 17:13:42 2020 +0200
ftp: make a 552 response return CURLE_REMOTE_DISK_FULL
Added test 348 to verify. Added a 'STOR' command to the test FTP
server to enable test 348. Documented the command in FILEFORMAT.md
Reported-by: Duncan Wilcox
Fixes #6016
Closes #6017
---
lib/ftp.c | 11 ++++++++-
tests/FILEFORMAT.md | 1 +
tests/data/Makefile.inc | 2 +-
tests/data/test348 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/ftpserver.pl | 17 +++++++++++++-
5 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/lib/ftp.c b/lib/ftp.c
index 3fd9cea2c..11031da6f 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3292,9 +3292,18 @@ static CURLcode ftp_done(struct connectdata *conn,
CURLcode status,
if(!ftpc->dont_check) {
/* 226 Transfer complete, 250 Requested file action okay, completed. */
- if((ftpcode != 226) && (ftpcode != 250)) {
+ switch(ftpcode) {
+ case 226:
+ case 250:
+ break;
+ case 552:
+ failf(data, "Exceeded storage allocation");
+ result = CURLE_REMOTE_DISK_FULL;
+ break;
+ default:
failf(data, "server did not report OK, got %d", ftpcode);
result = CURLE_PARTIAL_FILE;
+ break;
}
}
}
diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md
index c8f7e8391..09600d016 100644
--- a/tests/FILEFORMAT.md
+++ b/tests/FILEFORMAT.md
@@ -237,6 +237,7 @@ about to issue.
POP3 `CAPA` and SMTP `EHLO` commands
- `AUTH [mechanisms]` - Enables support for SASL authentication and specifies
a list of space separated mechanisms for IMAP, POP3 and SMTP
+- `STOR [msg]` respond with this instead of default after `STOR`
#### For HTTP/HTTPS
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index b4774a5f7..35932d11b 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -58,7 +58,7 @@ test307 test308 test309 test310 test311 test312 test313
test314 test315 \
test316 test317 test318 test319 test320 test321 test322 test323 test324 \
test325 test326 test327 test328 test329 test330 test331 test332 test333 \
test334 test335 test336 test337 test338 test339 test340 test341 test342 \
-test343 test344 test345 test346 test347 \
+test343 test344 test345 test346 test347 test348 \
test350 test351 test352 test353 test354 test355 test356 test357 test358 \
test359 \
test393 test394 test395 test396 test397 \
diff --git a/tests/data/test348 b/tests/data/test348
new file mode 100644
index 000000000..befd9fb81
--- /dev/null
+++ b/tests/data/test348
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+FTP
+EPSV
+STOR
+</keywords>
+</info>
+
+<reply>
+<servercmd>
+STOR 552 disk full
+</servercmd>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+ <name>
+FTP upload file with 552 disk full response
+ </name>
+<file name="log/test348.txt">
+data
+ to
+ see
+that FTP
+works
+ so does it?
+</file>
+ <command>
+ftp://%HOSTIP:%FTPPORT/348 -T log/test348.txt
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<upload>
+data
+ to
+ see
+that FTP
+works
+ so does it?
+</upload>
+<protocol>
+USER anonymous
+PASS ftp@example.com
+PWD
+EPSV
+TYPE I
+STOR 348
+QUIT
+</protocol>
+# 70 - CURLE_REMOTE_DISK_FULL
+<errorcode>
+70
+</errorcode>
+</verify>
+</testcase>
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index d587f453e..198ccd794 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -145,6 +145,7 @@ my $nodataconn; # set if ftp srvr doesn't establish or
accepts data channel
my $nodataconn425; # set if ftp srvr doesn't establish data ch and replies 425
my $nodataconn421; # set if ftp srvr doesn't establish data ch and replies 421
my $nodataconn150; # set if ftp srvr doesn't establish data ch and replies 150
+my $storeresp;
my @capabilities; # set if server supports capability commands
my @auth_mechs; # set if server supports authentication commands
my %fulltextreply; #
@@ -2413,6 +2414,10 @@ sub STOR_ftp {
logmsg "No support for: $line";
last;
}
+ if($storeresp) {
+ # abort early
+ last;
+ }
}
if($nosave) {
print FILE "$ulsize bytes would've been stored here\n";
@@ -2420,7 +2425,12 @@ sub STOR_ftp {
close(FILE);
close_dataconn($disc);
logmsg "received $ulsize bytes upload\n";
- sendcontrol "226 File transfer complete\r\n";
+ if($storeresp) {
+ sendcontrol "$storeresp\r\n";
+ }
+ else {
+ sendcontrol "226 File transfer complete\r\n";
+ }
return 0;
}
@@ -2784,6 +2794,7 @@ sub customize {
$nodataconn425 = 0; # default is to not send 425 without data channel
$nodataconn421 = 0; # default is to not send 421 without data channel
$nodataconn150 = 0; # default is to not send 150 without data channel
+ $storeresp = ""; # send as ultimate STOR response
@capabilities = (); # default is to not support capability commands
@auth_mechs = (); # default is to not support authentication commands
%fulltextreply = ();#
@@ -2866,6 +2877,10 @@ sub customize {
logmsg "FTPD: instructed to use NODATACONN\n";
$nodataconn=1;
}
+ elsif($_ =~ /^STOR (.*)/) {
+ $storeresp=$1;
+ logmsg "FTPD: instructed to use respond to STOR with
'$storeresp'\n";
+ }
elsif($_ =~ /CAPA (.*)/) {
logmsg "FTPD: instructed to support CAPABILITY command\n";
@capabilities = split(/ (?!(?:[^" ]|[^"] [^"])+")/, $1);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 180/411: pingpong: use a dynbuf for the *_pp_sendf() function, (continued)
- [gnurl] 180/411: pingpong: use a dynbuf for the *_pp_sendf() function, gnunet, 2021/01/12
- [gnurl] 143/411: test3015: verify stdout "as text", gnunet, 2021/01/12
- [gnurl] 150/411: multi: align WinSock mask variables in Curl_multi_wait, gnunet, 2021/01/12
- [gnurl] 145/411: CI/azure: disable test 571 in the msys2 builds, gnunet, 2021/01/12
- [gnurl] 163/411: docs/RESOURCES: remove, gnunet, 2021/01/12
- [gnurl] 169/411: krb5: merged security.c and krb specific FTP functions in here, gnunet, 2021/01/12
- [gnurl] 179/411: dynbuf: add Curl_dyn_vaddf, gnunet, 2021/01/12
- [gnurl] 137/411: vtls: deduplicate client certificates in ssl_config_data, gnunet, 2021/01/12
- [gnurl] 196/411: TODO: SSH over HTTPS proxy with more backends, gnunet, 2021/01/12
- [gnurl] 138/411: tool_urlglob: fix compiler warning "unreachable code", gnunet, 2021/01/12
- [gnurl] 189/411: ftp: make a 552 response return CURLE_REMOTE_DISK_FULL,
gnunet <=
- [gnurl] 236/411: projects/build-wolfssl.bat: fix the copyright year range, gnunet, 2021/01/12
- [gnurl] 212/411: curl: make --libcurl show binary posts correctly, gnunet, 2021/01/12
- [gnurl] 190/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 240/411: test122[12]: remove these two tests, gnunet, 2021/01/12
- [gnurl] 250/411: tool_operate: fix compiler warning when --libcurl is disabled, gnunet, 2021/01/12
- [gnurl] 218/411: ldap: reduce the amount of #ifdefs needed, gnunet, 2021/01/12
- [gnurl] 194/411: memdebug: remove 9 year old unused debug function, gnunet, 2021/01/12
- [gnurl] 187/411: test163[12]: require http to be built-in to run, gnunet, 2021/01/12
- [gnurl] 217/411: runtests: provide curl's version string as %VERSION for tests, gnunet, 2021/01/12
- [gnurl] 220/411: --help: move two options from the misc category, gnunet, 2021/01/12