summaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-09-21 13:59:33 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-09-21 14:16:25 +0200
commit6695bf4ae1e5a083f82134723ce305e312fa25b4 (patch)
tree71a5ec63e221d418c3ed5df282d264f59a6f3817 /lib/ftp.c
parent553588897ae821ff4f7af4f48efa74b80fffc528 (diff)
downloadcurl-6695bf4ae1e5a083f82134723ce305e312fa25b4.tar.gz
krb5: merged security.c and krb specific FTP functions in herebagder/ftp-krb5
These two files were always tightly connected and it was hard to understand what went into which. This also allows us to make the ftpsend() function static (moved from ftp.c). Removed security.c Renamed curl_sec.h to krb5.h
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c74
1 files changed, 4 insertions, 70 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 434401390..839d9a4ec 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -59,7 +59,7 @@
#include "fileinfo.h"
#include "ftplistparser.h"
#include "curl_range.h"
-#include "curl_sec.h"
+#include "krb5.h"
#include "strtoofft.h"
#include "strcase.h"
#include "vtls/vtls.h"
@@ -3945,64 +3945,6 @@ static CURLcode ftp_do(struct connectdata *conn, bool *done)
return result;
}
-
-CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
-{
- ssize_t bytes_written;
-#define SBUF_SIZE 1024
- char s[SBUF_SIZE];
- size_t write_len;
- char *sptr = s;
- CURLcode result = CURLE_OK;
-#ifdef HAVE_GSSAPI
- enum protection_level data_sec = conn->data_prot;
-#endif
-
- if(!cmd)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- write_len = strlen(cmd);
- if(!write_len || write_len > (sizeof(s) -3))
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- memcpy(&s, cmd, write_len);
- strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
- write_len += 2;
- bytes_written = 0;
-
- result = Curl_convert_to_network(conn->data, s, write_len);
- /* Curl_convert_to_network calls failf if unsuccessful */
- if(result)
- return result;
-
- for(;;) {
-#ifdef HAVE_GSSAPI
- conn->data_prot = PROT_CMD;
-#endif
- result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
- &bytes_written);
-#ifdef HAVE_GSSAPI
- DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
- conn->data_prot = data_sec;
-#endif
-
- if(result)
- break;
-
- if(conn->data->set.verbose)
- Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
-
- if(bytes_written != (ssize_t)write_len) {
- write_len -= bytes_written;
- sptr += bytes_written;
- }
- else
- break;
- }
-
- return result;
-}
-
/***********************************************************************
*
* ftp_quit()
@@ -4066,22 +4008,14 @@ static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
- free(ftpc->entrypath);
- ftpc->entrypath = NULL;
+ Curl_safefree(ftpc->entrypath);
}
freedirs(ftpc);
- free(ftpc->prevpath);
- ftpc->prevpath = NULL;
- free(ftpc->server_os);
- ftpc->server_os = NULL;
-
+ Curl_safefree(ftpc->prevpath);
+ Curl_safefree(ftpc->server_os);
Curl_pp_disconnect(pp);
-
-#ifdef HAVE_GSSAPI
Curl_sec_end(conn);
-#endif
-
return CURLE_OK;
}