mirror of https://github.com/moparisthebest/curl
ftp: fix Curl_ftpsendf()
... it no longer takes printf() arguments since it was only really taken advantage by one user and it was not written and used in a safe way. Thus the 'f' is removed from the function name and the proto is changed. Although the current code wouldn't end up in badness, it was a risk that future changes could end up springf()ing too large data or passing in a format string inadvertently.
This commit is contained in:
parent
9885c9508e
commit
8238ba9c5f
10
lib/ftp.c
10
lib/ftp.c
|
@ -4091,8 +4091,7 @@ static CURLcode ftp_do(struct connectdata *conn, bool *done)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CURLcode Curl_ftpsendf(struct connectdata *conn,
|
CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
|
||||||
const char *fmt, ...)
|
|
||||||
{
|
{
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
#define SBUF_SIZE 1024
|
#define SBUF_SIZE 1024
|
||||||
|
@ -4104,10 +4103,9 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||||
enum protection_level data_sec = conn->data_prot;
|
enum protection_level data_sec = conn->data_prot;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
va_list ap;
|
write_len = strlen(cmd);
|
||||||
va_start(ap, fmt);
|
if(write_len > (sizeof(s) -3))
|
||||||
write_len = vsnprintf(s, SBUF_SIZE-3, fmt, ap);
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
|
strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
|
||||||
write_len +=2;
|
write_len +=2;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -31,7 +31,7 @@ extern const struct Curl_handler Curl_handler_ftp;
|
||||||
extern const struct Curl_handler Curl_handler_ftps;
|
extern const struct Curl_handler Curl_handler_ftps;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
|
CURLcode Curl_ftpsend(struct connectdata *, const char *cmd);
|
||||||
CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn,
|
CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn,
|
||||||
int *ftpcode);
|
int *ftpcode);
|
||||||
#endif /* CURL_DISABLE_FTP */
|
#endif /* CURL_DISABLE_FTP */
|
||||||
|
|
12
lib/krb5.c
12
lib/krb5.c
|
@ -182,7 +182,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
|
||||||
for(;;) {
|
for(;;) {
|
||||||
/* this really shouldn't be repeated here, but can't help it */
|
/* this really shouldn't be repeated here, but can't help it */
|
||||||
if(service == srv_host) {
|
if(service == srv_host) {
|
||||||
result = Curl_ftpsendf(conn, "AUTH GSSAPI");
|
result = Curl_ftpsend(conn, "AUTH GSSAPI");
|
||||||
if(result)
|
if(result)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
@ -243,16 +243,22 @@ krb5_auth(void *app_data, struct connectdata *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(output_buffer.length != 0) {
|
if(output_buffer.length != 0) {
|
||||||
|
char *cmd;
|
||||||
|
|
||||||
result = Curl_base64_encode(data, (char *)output_buffer.value,
|
result = Curl_base64_encode(data, (char *)output_buffer.value,
|
||||||
output_buffer.length, &p, &base64_sz);
|
output_buffer.length, &p, &base64_sz);
|
||||||
if(result) {
|
if(result) {
|
||||||
Curl_infof(data, "base64-encoding: %s\n",
|
Curl_infof(data, "base64-encoding: %s\n",
|
||||||
curl_easy_strerror(result));
|
curl_easy_strerror(result));
|
||||||
ret = AUTH_CONTINUE;
|
ret = AUTH_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_ftpsendf(conn, "ADAT %s", p);
|
cmd = aprintf("ADAT %s", p);
|
||||||
|
if(cmd)
|
||||||
|
result = Curl_ftpsend(conn, cmd);
|
||||||
|
else
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ static int ftp_send_command(struct connectdata *conn, const char *message, ...)
|
||||||
vsnprintf(print_buffer, sizeof(print_buffer), message, args);
|
vsnprintf(print_buffer, sizeof(print_buffer), message, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if(Curl_ftpsendf(conn, print_buffer)) {
|
if(Curl_ftpsend(conn, print_buffer)) {
|
||||||
ftp_code = -1;
|
ftp_code = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue