]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid leaks on gss_accept_sec_context errors
authorSimo Sorce <simo@redhat.com>
Tue, 14 Aug 2012 13:14:15 +0000 (15:14 +0200)
committerGreg Hudson <ghudson@mit.edu>
Sun, 16 Sep 2012 15:08:58 +0000 (11:08 -0400)
Failure handling during the postprocessing of
mech->gss_accept_sec_context was inconsistent.  In one case we delete
the output token but leave the partly-constructed context present in
*context_handle (violating RFC 2744 if this is the first call); in
other cases we leave the output token in the caller's buffer but do
destroy the partly-constructed context.  Make this more consistent by
always destroying the output token and partly-constructed context.
(RFC 2744 prefers, but does not require, leaving the
partly-constructed context present on error if it was present on
entry.  At the moment we are ignoring that preference.)

[ghudson@mit.edu: Rewrote commit message with more details]

src/lib/gssapi/mechglue/g_accept_sec_context.c

index f6afc4517e7711102bc62d409133b7656018c6b0..85e41d310196c69388dc7e9258569415efc02711 100644 (file)
@@ -236,12 +236,10 @@ gss_cred_id_t *           d_cred;
                            &temp_minor_status, mech,
                            internal_name, &tmp_src_name);
                    if (temp_status != GSS_S_COMPLETE) {
+                       status = temp_status;
                        *minor_status = temp_minor_status;
                        map_error(minor_status, mech);
-                       if (output_token->length)
-                           (void) gss_release_buffer(&temp_minor_status,
-                                                     output_token);
-                       return (temp_status);
+                       goto error_out;
                    }
                    *src_name = tmp_src_name;
                } else
@@ -329,6 +327,9 @@ error_out:
        (void) gss_release_buffer(&temp_minor_status,
                                  (gss_buffer_t)tmp_src_name);
 
+    if (output_token->length)
+       (void) gss_release_buffer(&temp_minor_status, output_token);
+
     return (status);
 }
 #endif /* LEAN_CLIENT */