From: Greg Hudson Date: Fri, 13 Jul 2012 16:03:08 +0000 (-0400) Subject: Fix error handling in allocate_princ() X-Git-Tag: krb5-1.11-alpha1~418 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d938577dc1628f4dc8a0af3657020ee444a78c1b;p=thirdparty%2Fkrb5.git Fix error handling in allocate_princ() The most recent change could leak memory when trying to parse an invalid principal because of a failure to use the cleanup handler. --- diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 613e41d1ff..c55381aefb 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -79,8 +79,10 @@ allocate_princ(krb5_context context, const char *name, krb5_boolean enterprise, } else if (*p == '@' && (!enterprise || !first_at)) { /* Realm separator. In enterprise principals, the first one of * these we see is part of the component. */ - if (cur_data == &princ->realm) - return KRB5_PARSE_MALFORMED; + if (cur_data == &princ->realm) { + ret = KRB5_PARSE_MALFORMED; + goto cleanup; + } cur_data = &princ->realm; } else { /* Component or realm character, possibly quoted. Make note if