1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

krb5-gssapi: Remove several memory leaks.

Remove a leak seen on Kerberos/MIT (gss_OID is copied internally and
we were leaking it). Now we just pass NULL as advised in RFC2744.

|tmp| was never set back to buf->data.

Cleaned up Curl_sec_end to take into account failure in Curl_sec_login
(where conn->mech would be NULL but not conn->app_data or
conn->in_buffer->data).
This commit is contained in:
Julien Chaffraix 2010-09-26 22:44:42 -07:00
parent e3811ed7c3
commit 87badbef84
2 changed files with 14 additions and 5 deletions

View File

@ -218,8 +218,8 @@ krb5_auth(void *app_data, struct connectdata *conn)
continue; continue;
} }
{ {
gss_OID t; /* We pass NULL as |output_name_type| to avoid a leak. */
gss_display_name(&min, gssname, &gssbuf, &t); gss_display_name(&min, gssname, &gssbuf, NULL);
Curl_infof(data, "Trying against %s\n", gssbuf.value); Curl_infof(data, "Trying against %s\n", gssbuf.value);
gss_release_buffer(&min, &gssbuf); gss_release_buffer(&min, &gssbuf);
} }

View File

@ -216,6 +216,7 @@ static CURLcode read_data(struct connectdata *conn,
if (tmp == NULL) if (tmp == NULL)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
buf->data = tmp;
ret = socket_read(fd, buf->data, len); ret = socket_read(fd, buf->data, len);
if (ret != CURLE_OK) if (ret != CURLE_OK)
return ret; return ret;
@ -567,12 +568,20 @@ Curl_sec_login(struct connectdata *conn)
void void
Curl_sec_end(struct connectdata *conn) Curl_sec_end(struct connectdata *conn)
{ {
if(conn->mech != NULL) { if(conn->mech != NULL && conn->mech->end)
if(conn->mech->end) conn->mech->end(conn->app_data);
conn->mech->end(conn->app_data); if(conn->app_data) {
free(conn->app_data); free(conn->app_data);
conn->app_data = NULL; conn->app_data = NULL;
} }
if(conn->in_buffer.data) {
free(conn->in_buffer.data);
conn->in_buffer.data = NULL;
conn->in_buffer.size = 0;
conn->in_buffer.index = 0;
/* FIXME: Is this really needed? */
conn->in_buffer.eof_flag = 0;
}
conn->sec_complete = 0; conn->sec_complete = 0;
conn->data_prot = (enum protection_level)0; conn->data_prot = (enum protection_level)0;
conn->mech = NULL; conn->mech = NULL;