From 3ceb437bee2c48950e5b4131164276870b40f8e7 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Thu, 14 Aug 2008 16:40:07 +0000 Subject: [PATCH] In parsing principal - if run out memory - clean up after ourselves. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20658 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/cc_file.c | 11 +++++++++-- src/lib/krb5/ccache/cc_keyring.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index f69d4929c..0e5a9b666 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -503,6 +503,7 @@ krb5_fcc_read_principal(krb5_context context, krb5_ccache id, krb5_principal *pr errout: while(--i >= 0) free(krb5_princ_component(context, tmpprinc, i)->data); + krb5_xfree(krb5_princ_realm(context, tmpprinc)->data); free((char *)tmpprinc->data); free((char *)tmpprinc); return kret; @@ -1807,9 +1808,15 @@ krb5_fcc_start_seq_get(krb5_context context, krb5_ccache id, /* Make sure we start reading right after the primary principal */ kret = krb5_fcc_skip_header(context, id); - if (kret) goto done; + if (kret) { + krb5_xfree(fcursor); + goto done; + } kret = krb5_fcc_skip_principal(context, id); - if (kret) goto done; + if (kret) { + krb5_xfree(fcursor); + goto done; + } fcursor->pos = fcc_lseek(data, (off_t) 0, SEEK_CUR); *cursor = (krb5_cc_cursor) fcursor; diff --git a/src/lib/krb5/ccache/cc_keyring.c b/src/lib/krb5/ccache/cc_keyring.c index 163ad30f7..d892584fe 100644 --- a/src/lib/krb5/ccache/cc_keyring.c +++ b/src/lib/krb5/ccache/cc_keyring.c @@ -1360,6 +1360,7 @@ krb5_krcc_parse_principal(krb5_context context, krb5_ccache id, errout: while (--i >= 0) free(krb5_princ_component(context, tmpprinc, i)->data); + krb5_xfree(krb5_princ_realm(context, tmpprinc)->data); free((char *) tmpprinc->data); free((char *) tmpprinc); return kret; -- 2.26.2