From af2d679e1414369f23a2d37a113634b0ac7f38b0 Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Mon, 22 Aug 2016 15:37:03 -0400 Subject: errors: new alias CURLE_WEIRD_SERVER_REPLY (8) Since we're using CURLE_FTP_WEIRD_SERVER_REPLY in imap, pop3 and smtp as more of a generic "failed to parse" introduce an alias without FTP in the name. Closes https://github.com/curl/curl/pull/975 --- docs/curl.1 | 2 +- docs/libcurl/libcurl-errors.3 | 5 ++--- docs/libcurl/symbols-in-versions | 1 + include/curl/curl.h | 3 ++- lib/ftp.c | 6 +++--- lib/imap.c | 8 ++++---- lib/pop3.c | 2 +- lib/smtp.c | 2 +- lib/strerror.c | 4 ++-- packages/OS400/curl.inc.in | 2 ++ packages/vms/curlmsg.h | 3 ++- packages/vms/curlmsg.msg | 2 +- packages/vms/curlmsg.sdl | 1 + packages/vms/curlmsg_vms.h | 2 +- tests/data/test2045 | 4 ++-- 15 files changed, 26 insertions(+), 21 deletions(-) diff --git a/docs/curl.1 b/docs/curl.1 index 7a6cbbd5a..9f657ddb3 100644 --- a/docs/curl.1 +++ b/docs/curl.1 @@ -2254,7 +2254,7 @@ Couldn't resolve host. The given remote host was not resolved. .IP 7 Failed to connect to host. .IP 8 -FTP weird server reply. The server sent data curl couldn't parse. +Weird server reply. The server sent data curl couldn't parse. .IP 9 FTP access denied. The server denied login or denied access to the particular resource or directory you wanted to reach. Most often you tried to change to a diff --git a/docs/libcurl/libcurl-errors.3 b/docs/libcurl/libcurl-errors.3 index 0a21a7589..1b6e34f51 100644 --- a/docs/libcurl/libcurl-errors.3 +++ b/docs/libcurl/libcurl-errors.3 @@ -60,9 +60,8 @@ Couldn't resolve host. The given remote host was not resolved. .IP "CURLE_COULDNT_CONNECT (7)" Failed to connect() to host or proxy. .IP "CURLE_FTP_WEIRD_SERVER_REPLY (8)" -After connecting to a FTP server, libcurl expects to get a certain reply -back. This error code implies that it got a strange or bad reply. The given -remote server is probably not an OK FTP server. +The server sent data libcurl couldn't parse. This error code is used for more +than just FTP and is aliased as \fICURLE_WEIRD_SERVER_REPLY\fP since 7.51.0. .IP "CURLE_REMOTE_ACCESS_DENIED (9)" We were denied access to the resource given in the URL. For FTP, this occurs while trying to change to the remote directory. diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions index 5aadef2a6..e61319546 100644 --- a/docs/libcurl/symbols-in-versions +++ b/docs/libcurl/symbols-in-versions @@ -140,6 +140,7 @@ CURLE_UPLOAD_FAILED 7.16.3 CURLE_URL_MALFORMAT 7.1 CURLE_URL_MALFORMAT_USER 7.1 7.17.0 CURLE_USE_SSL_FAILED 7.17.0 +CURLE_WEIRD_SERVER_REPLY 7.51.0 CURLE_WRITE_ERROR 7.1 CURLFILETYPE_DEVICE_BLOCK 7.21.0 CURLFILETYPE_DEVICE_CHAR 7.21.0 diff --git a/include/curl/curl.h b/include/curl/curl.h index bba1e6d3b..0ac238c28 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -435,7 +435,7 @@ typedef enum { CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ CURLE_COULDNT_RESOLVE_HOST, /* 6 */ CURLE_COULDNT_CONNECT, /* 7 */ - CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_WEIRD_SERVER_REPLY, /* 8 */ CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server due to lack of access - when login fails this is not returned. */ @@ -566,6 +566,7 @@ typedef enum { /* compatibility with older names */ #define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING +#define CURLE_FTP_WEIRD_SERVER_REPLY CURLE_WEIRD_SERVER_REPLY /* The following were added in 7.21.5, April 2011 */ #define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION diff --git a/lib/ftp.c b/lib/ftp.c index 4c369973f..3e8a22be9 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -475,7 +475,7 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received) if(ftpcode/100 > 3) return CURLE_FTP_ACCEPT_FAILED; - return CURLE_FTP_WEIRD_SERVER_REPLY; + return CURLE_WEIRD_SERVER_REPLY; } break; @@ -1835,7 +1835,7 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn) if(conn->bits.ipv6) { /* We can't disable EPSV when doing IPv6, so this is instead a fail */ failf(conn->data, "Failed EPSV attempt, exiting\n"); - return CURLE_FTP_WEIRD_SERVER_REPLY; + return CURLE_WEIRD_SERVER_REPLY; } infof(conn->data, "Failed EPSV attempt. Disabling EPSV\n"); @@ -2742,7 +2742,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) else if(ftpcode != 220) { failf(data, "Got a %03d ftp-server response when 220 was expected", ftpcode); - return CURLE_FTP_WEIRD_SERVER_REPLY; + return CURLE_WEIRD_SERVER_REPLY; } /* We have received a 220 response fine, now we proceed. */ diff --git a/lib/imap.c b/lib/imap.c index 123ea3b26..50a351284 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -846,7 +846,7 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn, if(imapcode != 'O') { failf(data, "Got unexpected imap-server response"); - result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: fix this code */ + result = CURLE_WEIRD_SERVER_REPLY; } else result = imap_perform_capability(conn); @@ -1179,7 +1179,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, else { /* We don't know how to parse this line */ failf(pp->conn->data, "Failed to parse FETCH response."); - result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: fix this code */ + result = CURLE_WEIRD_SERVER_REPLY; } /* End of DO phase */ @@ -1198,7 +1198,7 @@ static CURLcode imap_state_fetch_final_resp(struct connectdata *conn, (void)instate; /* No use for this yet */ if(imapcode != 'O') - result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: Fix error code */ + result = CURLE_WEIRD_SERVER_REPLY; else /* End of DONE phase */ state(conn, IMAP_STOP); @@ -1275,7 +1275,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn) /* Was there an error parsing the response line? */ if(imapcode == -1) - return CURLE_FTP_WEIRD_SERVER_REPLY; + return CURLE_WEIRD_SERVER_REPLY; if(!imapcode) break; diff --git a/lib/pop3.c b/lib/pop3.c index 591e877f5..154e5c38b 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -663,7 +663,7 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn, if(pop3code != '+') { failf(data, "Got unexpected pop3-server response"); - result = CURLE_FTP_WEIRD_SERVER_REPLY; + result = CURLE_WEIRD_SERVER_REPLY; } else { /* Does the server support APOP authentication? */ diff --git a/lib/smtp.c b/lib/smtp.c index d203b5323..98504df79 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -674,7 +674,7 @@ static CURLcode smtp_state_servergreet_resp(struct connectdata *conn, if(smtpcode/100 != 2) { failf(data, "Got unexpected smtp-server response: %d", smtpcode); - result = CURLE_FTP_WEIRD_SERVER_REPLY; + result = CURLE_WEIRD_SERVER_REPLY; } else result = smtp_perform_ehlo(conn); diff --git a/lib/strerror.c b/lib/strerror.c index 0e268d5e3..9c58e6b77 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -79,8 +79,8 @@ curl_easy_strerror(CURLcode error) case CURLE_COULDNT_CONNECT: return "Couldn't connect to server"; - case CURLE_FTP_WEIRD_SERVER_REPLY: - return "FTP: weird server reply"; + case CURLE_WEIRD_SERVER_REPLY: + return "Weird server reply"; case CURLE_REMOTE_ACCESS_DENIED: return "Access denied to remote resource"; diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in index 1e8a93dd1..486f655e9 100644 --- a/packages/OS400/curl.inc.in +++ b/packages/OS400/curl.inc.in @@ -369,6 +369,8 @@ d c 6 d CURLE_COULDNT_CONNECT... d c 7 + d CURLE_WEIRD_SERVER_REPLY... + d c 8 d CURLE_FTP_WEIRD_SERVER_REPLY... d c 8 d CURLE_REMOTE_ACCESS_DENIED... diff --git a/packages/vms/curlmsg.h b/packages/vms/curlmsg.h index 2cb32ec1c..424a382f0 100644 --- a/packages/vms/curlmsg.h +++ b/packages/vms/curlmsg.h @@ -57,7 +57,8 @@ #define CURL_COULDNT_RESOLVE_PROXY 251756594 #define CURL_COULDNT_RESOLVE_HOST 251756602 #define CURL_COULDNT_CONNECT 251756610 -#define CURL_FTP_WEIRD_SERVER_REPLY 251756618 +#define CURL_WEIRD_SERVER_REPLY 251756618 +#define CURL_FTP_WEIRD_SERVER_REPLY CURL_WEIRD_SERVER_REPLY #define CURL_FTP_ACCESS_DENIED 251756626 #define CURL_OBSOLETE10 251756634 #define CURL_FTP_WEIRD_PASS_REPLY 251756642 diff --git a/packages/vms/curlmsg.msg b/packages/vms/curlmsg.msg index 7fd448353..492657c02 100644 --- a/packages/vms/curlmsg.msg +++ b/packages/vms/curlmsg.msg @@ -30,7 +30,7 @@ OBSOLETE4 COULDNT_RESOLVE_PROXY COULDNT_RESOLVE_HOST COULDNT_CONNECT -FTP_WEIRD_SERVER_REPLY +WEIRD_SERVER_REPLY FTP_ACCESS_DENIED OBSOLETE10 FTP_WEIRD_PASS_REPLY diff --git a/packages/vms/curlmsg.sdl b/packages/vms/curlmsg.sdl index e192c0750..db5baad60 100644 --- a/packages/vms/curlmsg.sdl +++ b/packages/vms/curlmsg.sdl @@ -34,6 +34,7 @@ ,"COULDNT_RESOLVE_PROXY" EQUALS %X0F018032 PREFIX "CURL" TAG "" ,"COULDNT_RESOLVE_HOST" EQUALS %X0F01803A PREFIX "CURL" TAG "" ,"COULDNT_CONNECT" EQUALS %X0F018042 PREFIX "CURL" TAG "" + ,"WEIRD_SERVER_REPLY" EQUALS %X0F01804A PREFIX "CURL" TAG "" ,"FTP_WEIRD_SERVER_REPLY" EQUALS %X0F01804A PREFIX "CURL" TAG "" ,"FTP_ACCESS_DENIED" EQUALS %X0F018052 PREFIX "CURL" TAG "" ,"OBSOLETE10" EQUALS %X0F01805A PREFIX "CURL" TAG "" diff --git a/packages/vms/curlmsg_vms.h b/packages/vms/curlmsg_vms.h index 3aef9cfea..b7ff7a0cb 100644 --- a/packages/vms/curlmsg_vms.h +++ b/packages/vms/curlmsg_vms.h @@ -59,7 +59,7 @@ static const long vms_cond[] = CURL_COULDNT_RESOLVE_PROXY, CURL_COULDNT_RESOLVE_HOST, CURL_COULDNT_CONNECT, - CURL_FTP_WEIRD_SERVER_REPLY, + CURL_WEIRD_SERVER_REPLY, CURL_FTP_ACCESS_DENIED, CURL_OBSOLETE10, CURL_FTP_WEIRD_PASS_REPLY, diff --git a/tests/data/test2045 b/tests/data/test2045 index 3190f803b..15647d3e7 100644 --- a/tests/data/test2045 +++ b/tests/data/test2045 @@ -19,7 +19,7 @@ In the broken scenario curl would use HTTP to talk to our FTP server. We handle that by replying with something that both protocols can understand. Our FTP server allows a custom welcome message, so we use that feature to make an HTTP reply that contains an FTP reply (think polyglot). In the case of FTP we expect -curl will return CURLE_FTP_WEIRD_SERVER_REPLY so we test for that return code. +curl will return CURLE_WEIRD_SERVER_REPLY so we test for that return code. --> REPLY welcome HTTP/1.1 200 OK\r\nContent-Length: 21\r\n\r\n500 Weird FTP Reply @@ -46,7 +46,7 @@ Set the default protocol to ftp for a schemeless URL # # Verify data after the test has been "shot" -# CURLE_FTP_WEIRD_SERVER_REPLY is error code 8 +# CURLE_WEIRD_SERVER_REPLY is error code 8 8 -- cgit v1.2.3