summaryrefslogtreecommitdiff
path: root/lib/krb5.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-04-25 14:37:45 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-05-01 22:55:29 +0200
commitc79f4908d461cecaa9976099dcbb8a63b351f19e (patch)
treed80543f9efebe5eb71f1fae8ec37fc376df4728a /lib/krb5.c
parent89cf6f38d2f525cbc8537a60061f5f37bb2f35f7 (diff)
downloadcurl-c79f4908d461cecaa9976099dcbb8a63b351f19e.tar.gz
krb5: use private buffer for temp string, not receive buffer
Diffstat (limited to 'lib/krb5.c')
-rw-r--r--lib/krb5.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/krb5.c b/lib/krb5.c
index 067b0a577..69a35979a 100644
--- a/lib/krb5.c
+++ b/lib/krb5.c
@@ -164,6 +164,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
size_t base64_sz = 0;
struct sockaddr_in **remote_addr =
(struct sockaddr_in **)&conn->ip_addr->ai_addr;
+ char *stringp;
if(getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)&conn->local_addr, &l) < 0)
@@ -193,16 +194,19 @@ krb5_auth(void *app_data, struct connectdata *conn)
return -1;
}
- input_buffer.value = data->state.buffer;
- input_buffer.length = snprintf(input_buffer.value, BUFSIZE, "%s@%s",
- service, host);
+ stringp = aprintf("%s@%s", service, host);
+ if(!stringp)
+ return -2;
+
+ input_buffer.value = stringp;
+ input_buffer.length = strlen(stringp);
maj = gss_import_name(&min, &input_buffer, GSS_C_NT_HOSTBASED_SERVICE,
&gssname);
+ free(stringp);
if(maj != GSS_S_COMPLETE) {
gss_release_name(&min, &gssname);
if(service == srv_host) {
- Curl_failf(data, "Error importing service name %s",
- input_buffer.value);
+ Curl_failf(data, "Error importing service name %s@%s", service, host);
return AUTH_ERROR;
}
service = srv_host;