summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/krb
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2012-07-13 12:03:08 -0400
committerGreg Hudson <ghudson@mit.edu>2012-07-13 12:03:08 -0400
commitd938577dc1628f4dc8a0af3657020ee444a78c1b (patch)
treea1023ec5ae3ca4c65c0dc1cb374428e4116c3713 /src/lib/krb5/krb
parentb17ceb2c87a1513e18ba793b6ea183ff76faaca8 (diff)
downloadkrb5-d938577dc1628f4dc8a0af3657020ee444a78c1b.tar.gz
krb5-d938577dc1628f4dc8a0af3657020ee444a78c1b.tar.xz
krb5-d938577dc1628f4dc8a0af3657020ee444a78c1b.zip
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.
Diffstat (limited to 'src/lib/krb5/krb')
-rw-r--r--src/lib/krb5/krb/parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c
index 613e41d1f..c55381aef 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