From c7cca1c8f7e9bfbd81b49107d88aa4a4ca2071d0 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Thu, 12 Jul 2007 14:13:06 +0000 Subject: Fix freenig of names in Kerberos when using MIT - need to use the free function provided in the Kerberos library. This fixes a very hard to track down heap corruption on windows when using debug runtimes. --- src/include/pg_config.h.in | 3 +++ src/interfaces/libpq/fe-auth.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 7c1ac6b69bf..655d0948e17 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -209,6 +209,9 @@ /* Define to 1 if `text.data' is member of `krb5_error'. */ #undef HAVE_KRB5_ERROR_TEXT_DATA +/* Define to 1 if you have krb5_free_unparsed_name */ +#undef HAVE_KRB5_FREE_UNPARSED_NAME + /* Define to 1 if `client' is member of `krb5_ticket'. */ #undef HAVE_KRB5_TICKET_CLIENT diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 7725f52f354..d1f1a5c480c 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.121 2006/10/04 00:30:12 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.121.2.1 2007/07/12 14:13:06 mha Exp $ * *------------------------------------------------------------------------- */ @@ -63,6 +63,18 @@ #include #endif +/* + * Heimdal doesn't have a free function for unparsed names. Just pass it to + * standard free() which should work in these cases. + */ +#ifndef HAVE_KRB5_FREE_UNPARSED_NAME +static void +krb5_free_unparsed_name(krb5_context context, char *val) +{ + free(val); +} +#endif + /* * pg_an_to_ln -- return the local name corresponding to an authentication * name @@ -180,8 +192,8 @@ pg_krb5_destroy(struct krb5_info * info) { krb5_free_principal(info->pg_krb5_context, info->pg_krb5_client); krb5_cc_close(info->pg_krb5_context, info->pg_krb5_ccache); + krb5_free_unparsed_name(info->pg_krb5_context, info->pg_krb5_name); krb5_free_context(info->pg_krb5_context); - free(info->pg_krb5_name); } -- cgit v1.2.3