]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix error handling in allocate_princ()
authorGreg Hudson <ghudson@mit.edu>
Fri, 13 Jul 2012 16:03:08 +0000 (12:03 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 13 Jul 2012 16:03:08 +0000 (12:03 -0400)
The most recent change could leak memory when trying to parse an
invalid principal because of a failure to use the cleanup handler.

src/lib/krb5/krb/parse.c

index 613e41d1ff371ff667308bde4c3607642a0f7def..c55381aefb687efbab382b9fbeeb9e9187b787fa 100644 (file)
@@ -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