summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/krb5.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/krb5.c')
-rw-r--r--Utilities/cmcurl/lib/krb5.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/Utilities/cmcurl/lib/krb5.c b/Utilities/cmcurl/lib/krb5.c
index a1102e5..4db19fb 100644
--- a/Utilities/cmcurl/lib/krb5.c
+++ b/Utilities/cmcurl/lib/krb5.c
@@ -1,6 +1,6 @@
/* GSSAPI/krb5 support for FTP - loosely based on old krb4.c
*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* Copyright (C) Daniel Stenberg
* All rights reserved.
@@ -75,8 +75,7 @@ static CURLcode ftpsend(struct Curl_easy *data, struct connectdata *conn,
unsigned char data_sec = conn->data_prot;
#endif
- if(!cmd)
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ DEBUGASSERT(cmd);
write_len = strlen(cmd);
if(!write_len || write_len > (sizeof(s) -3))
@@ -236,9 +235,12 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn)
if(Curl_GetFTPResponse(data, &nread, NULL))
return -1;
-
- if(data->state.buffer[0] != '3')
- return -1;
+ else {
+ struct pingpong *pp = &conn->proto.ftpc.pp;
+ char *line = Curl_dyn_ptr(&pp->recvbuf);
+ if(line[0] != '3')
+ return -1;
+ }
}
stringp = aprintf("%s@%s", service, host);
@@ -322,15 +324,19 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn)
ret = -1;
break;
}
-
- if(data->state.buffer[0] != '2' && data->state.buffer[0] != '3') {
- infof(data, "Server didn't accept auth data");
- ret = AUTH_ERROR;
- break;
+ else {
+ struct pingpong *pp = &conn->proto.ftpc.pp;
+ size_t len = Curl_dyn_len(&pp->recvbuf);
+ p = Curl_dyn_ptr(&pp->recvbuf);
+ if((len < 4) || (p[0] != '2' && p[0] != '3')) {
+ infof(data, "Server didn't accept auth data");
+ ret = AUTH_ERROR;
+ break;
+ }
}
_gssresp.value = NULL; /* make sure it is initialized */
- p = data->state.buffer + 4;
+ p += 4; /* over '789 ' */
p = strstr(p, "ADAT=");
if(p) {
result = Curl_base64_decode(p + 5,
@@ -417,7 +423,6 @@ static char level_to_char(int level)
case PROT_PRIVATE:
return 'P';
case PROT_CMD:
- /* Fall through */
default:
/* Those 2 cases should not be reached! */
break;
@@ -430,6 +435,9 @@ static char level_to_char(int level)
/* Send an FTP command defined by |message| and the optional arguments. The
function returns the ftp_code. If an error occurs, -1 is returned. */
static int ftp_send_command(struct Curl_easy *data, const char *message, ...)
+ CURL_PRINTF(2, 3);
+
+static int ftp_send_command(struct Curl_easy *data, const char *message, ...)
{
int ftp_code;
ssize_t nread = 0;
@@ -750,6 +758,8 @@ static int sec_set_protection_level(struct Curl_easy *data)
if(level) {
char *pbsz;
unsigned int buffer_size = 1 << 20; /* 1048576 */
+ struct pingpong *pp = &conn->proto.ftpc.pp;
+ char *line;
code = ftp_send_command(data, "PBSZ %u", buffer_size);
if(code < 0)
@@ -761,10 +771,11 @@ static int sec_set_protection_level(struct Curl_easy *data)
}
conn->buffer_size = buffer_size;
- pbsz = strstr(data->state.buffer, "PBSZ=");
+ line = Curl_dyn_ptr(&pp->recvbuf);
+ pbsz = strstr(line, "PBSZ=");
if(pbsz) {
/* stick to default value if the check fails */
- if(!strncmp(pbsz, "PBSZ=", 5) && ISDIGIT(pbsz[5]))
+ if(ISDIGIT(pbsz[5]))
buffer_size = atoi(&pbsz[5]);
if(buffer_size < conn->buffer_size)
conn->buffer_size = buffer_size;