From 955414824eb55c653811f522bcfe47fa8dd67d31 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 23 Sep 1994 01:39:18 +0000 Subject: [PATCH] Make sure memory associated the credentials cache is freed after the cache is destroyed. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4334 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/file/ChangeLog | 5 +++++ src/lib/krb5/ccache/file/fcc_destry.c | 19 +++++++++++++------ src/lib/krb5/ccache/stdio/ChangeLog | 5 +++++ src/lib/krb5/ccache/stdio/scc_destry.c | 13 +++++++++---- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/lib/krb5/ccache/file/ChangeLog b/src/lib/krb5/ccache/file/ChangeLog index 97748b5d2..cc2628fba 100644 --- a/src/lib/krb5/ccache/file/ChangeLog +++ b/src/lib/krb5/ccache/file/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 22 21:37:15 1994 Theodore Y. Ts'o (tytso@dcl) + + * fcc_destry.c (krb5_fcc_destroy): Make sure memory associated + with the credentials cache is freed after it is destroyed. + Thu Aug 18 16:33:33 1994 Theodore Y. Ts'o (tytso at tsx-11) * fcc_retrv.c (srvname_match): Fix bug in srvname_match where so diff --git a/src/lib/krb5/ccache/file/fcc_destry.c b/src/lib/krb5/ccache/file/fcc_destry.c index be385c0af..1433346f8 100644 --- a/src/lib/krb5/ccache/file/fcc_destry.c +++ b/src/lib/krb5/ccache/file/fcc_destry.c @@ -45,8 +45,10 @@ krb5_error_code krb5_fcc_destroy(id) if (OPENCLOSE(id)) { ret = open(((krb5_fcc_data *) id->data)->filename, O_RDWR, 0); - if (ret < 0) - return krb5_fcc_interpret(errno); + if (ret < 0) { + ret = krb5_fcc_interpret(errno); + goto cleanup; + } ((krb5_fcc_data *) id->data)->fd = ret; } else @@ -59,7 +61,7 @@ krb5_error_code krb5_fcc_destroy(id) (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; } - return ret; + goto cleanup; } ret = fstat(((krb5_fcc_data *) id->data)->fd, &buf); @@ -69,7 +71,7 @@ krb5_error_code krb5_fcc_destroy(id) (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; } - return ret; + goto cleanup; } /* XXX This may not be legal XXX */ @@ -83,7 +85,7 @@ krb5_error_code krb5_fcc_destroy(id) (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; } - return ret; + goto cleanup; } if (write(((krb5_fcc_data *) id->data)->fd, zeros, size % BUFSIZ) < 0) { @@ -92,7 +94,7 @@ krb5_error_code krb5_fcc_destroy(id) (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; } - return ret; + goto cleanup; } ret = close(((krb5_fcc_data *) id->data)->fd); @@ -101,5 +103,10 @@ krb5_error_code krb5_fcc_destroy(id) if (ret) ret = krb5_fcc_interpret(errno); + cleanup: + xfree(((krb5_fcc_data *) id->data)->filename); + xfree(id->data); + xfree(id); + return ret; } diff --git a/src/lib/krb5/ccache/stdio/ChangeLog b/src/lib/krb5/ccache/stdio/ChangeLog index 56d6d4fb3..b7976942b 100644 --- a/src/lib/krb5/ccache/stdio/ChangeLog +++ b/src/lib/krb5/ccache/stdio/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 22 21:38:09 1994 Theodore Y. Ts'o (tytso@dcl) + + * scc_destry.c (krb5_scc_destroy): Make sure memory associated + with the credentials cache is freed after it is destroyed. + Thu Aug 18 16:34:51 1994 Theodore Y. Ts'o (tytso at tsx-11) * scc_retrv.c (srvname_match): Fix bug in srvname_match where so diff --git a/src/lib/krb5/ccache/stdio/scc_destry.c b/src/lib/krb5/ccache/stdio/scc_destry.c index 1691692dd..4555c6f4b 100644 --- a/src/lib/krb5/ccache/stdio/scc_destry.c +++ b/src/lib/krb5/ccache/stdio/scc_destry.c @@ -61,7 +61,7 @@ krb5_error_code krb5_scc_destroy(id) (void) fclose(data->file); data->file = 0; } - return ret; + goto cleanup; } #if 0 @@ -77,7 +77,7 @@ krb5_error_code krb5_scc_destroy(id) (void) fclose(data->file); data->file = 0; } - return ret; + goto cleanup; } /* XXX This may not be legal XXX */ @@ -91,7 +91,7 @@ krb5_error_code krb5_scc_destroy(id) (void) fclose(data->file); data->file = 0; } - return ret; + goto cleanup; } if (fwrite(data->file, zeros, size % BUFSIZ) < 0) { @@ -100,7 +100,7 @@ krb5_error_code krb5_scc_destroy(id) (void) fclose(data->file); data->file = 0; } - return ret; + goto cleanup; } ret = fclose(data->file); @@ -110,5 +110,10 @@ krb5_error_code krb5_scc_destroy(id) if (ret) ret = krb5_scc_interpret(errno); + cleanup: + xfree(data->filename); + xfree(data); + xfree(id); + return ret; } -- 2.26.2