Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6771994

Browse files
committed
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 windowswhen using debug runtimes.
1 parent05c4d8f commit6771994

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

‎configure

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14398,6 +14398,64 @@ fi
1439814398

1439914399
fi
1440014400

14401+
14402+
# Win32 requires headers to be loaded for __stdcall, so can't use
14403+
# AC_CHECK_FUNCS here.
14404+
echo "$as_me:$LINENO: checking for krb5_free_unparsed_name" >&5
14405+
echo $ECHO_N "checking for krb5_free_unparsed_name... $ECHO_C" >&6
14406+
cat >conftest.$ac_ext <<_ACEOF
14407+
/* confdefs.h. */
14408+
_ACEOF
14409+
cat confdefs.h >>conftest.$ac_ext
14410+
cat >>conftest.$ac_ext <<_ACEOF
14411+
/* end confdefs.h. */
14412+
#include <krb5.h>
14413+
int
14414+
main ()
14415+
{
14416+
krb5_free_unparsed_name(NULL,NULL);
14417+
;
14418+
return 0;
14419+
}
14420+
_ACEOF
14421+
rm -f conftest.$ac_objext conftest$ac_exeext
14422+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
14423+
(eval $ac_link) 2>conftest.er1
14424+
ac_status=$?
14425+
grep -v '^ *+' conftest.er1 >conftest.err
14426+
rm -f conftest.er1
14427+
cat conftest.err >&5
14428+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
14429+
(exit $ac_status); } &&
14430+
{ ac_try='test -z "$ac_c_werror_flag"
14431+
|| test ! -s conftest.err'
14432+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
14433+
(eval $ac_try) 2>&5
14434+
ac_status=$?
14435+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
14436+
(exit $ac_status); }; } &&
14437+
{ ac_try='test -s conftest$ac_exeext'
14438+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
14439+
(eval $ac_try) 2>&5
14440+
ac_status=$?
14441+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
14442+
(exit $ac_status); }; }; then
14443+
14444+
cat >>confdefs.h <<\_ACEOF
14445+
#define HAVE_KRB5_FREE_UNPARSED_NAME 1
14446+
_ACEOF
14447+
14448+
echo "$as_me:$LINENO: result: yes" >&5
14449+
echo "${ECHO_T}yes" >&6
14450+
else
14451+
echo "$as_me: failed program was:" >&5
14452+
sed 's/^/| /' conftest.$ac_ext >&5
14453+
14454+
echo "$as_me:$LINENO: result: no" >&5
14455+
echo "${ECHO_T}no" >&6
14456+
fi
14457+
rm -f conftest.err conftest.$ac_objext \
14458+
conftest$ac_exeext conftest.$ac_ext
1440114459
fi
1440214460

1440314461

‎configure.in

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.518 2007/07/10 16:41:01 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.519 2007/07/12 14:10:39 mha Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -965,6 +965,15 @@ if test "$with_krb5" = yes; then
965965
[AC_MSG_ERROR([could not determine how to extract Kerberos 5 error messages])],
966966
[#include <krb5.h>])],
967967
[#include <krb5.h>])
968+
969+
# Win32 requires headers to be loaded for __stdcall, so can't use
970+
# AC_CHECK_FUNCS here.
971+
AC_MSG_CHECKING(for krb5_free_unparsed_name)
972+
AC_TRY_LINK([#include <krb5.h>],
973+
[krb5_free_unparsed_name(NULL,NULL);],
974+
[AC_DEFINE(HAVE_KRB5_FREE_UNPARSED_NAME, 1, [Define to 1 if you have krb5_free_unparsed_name])
975+
AC_MSG_RESULT(yes)],
976+
[AC_MSG_RESULT(no)])
968977
fi
969978

970979

‎src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@
214214
/* Define to 1 if `text.data' is member of `krb5_error'. */
215215
#undef HAVE_KRB5_ERROR_TEXT_DATA
216216

217+
/* Define to 1 if you have krb5_free_unparsed_name */
218+
#undef HAVE_KRB5_FREE_UNPARSED_NAME
219+
217220
/* Define to 1 if `client' is member of `krb5_ticket'. */
218221
#undef HAVE_KRB5_TICKET_CLIENT
219222

‎src/interfaces/libpq/fe-auth.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.124 2007/07/10 13:14:21 mha Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.125 2007/07/1214:10:39 mha Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -63,6 +63,18 @@
6363
#include<com_err.h>
6464
#endif
6565

66+
/*
67+
* Heimdal doesn't have a free function for unparsed names. Just pass it to
68+
* standard free() which should work in these cases.
69+
*/
70+
#ifndefHAVE_KRB5_FREE_UNPARSED_NAME
71+
staticvoid
72+
krb5_free_unparsed_name(krb5_contextcontext,char*val)
73+
{
74+
free(val);
75+
}
76+
#endif
77+
6678
/*
6779
* pg_an_to_ln -- return the local name corresponding to an authentication
6880
* name
@@ -180,8 +192,8 @@ pg_krb5_destroy(struct krb5_info * info)
180192
{
181193
krb5_free_principal(info->pg_krb5_context,info->pg_krb5_client);
182194
krb5_cc_close(info->pg_krb5_context,info->pg_krb5_ccache);
195+
krb5_free_unparsed_name(info->pg_krb5_context,info->pg_krb5_name);
183196
krb5_free_context(info->pg_krb5_context);
184-
free(info->pg_krb5_name);
185197
}
186198

187199

‎src/tools/msvc/Solution.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Solution;
33
#
44
# Package that encapsulates a Visual C++ solution file generation
55
#
6-
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.27 2007/06/20 17:19:00 adunstan Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.28 2007/07/12 14:10:39 mha Exp $
77
#
88
use Carp;
99
use strict;
@@ -123,6 +123,7 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
123123
print O"#define KRB5 1\n";
124124
print O"#define HAVE_KRB5_ERROR_TEXT_DATA 1\n";
125125
print O"#define HAVE_KRB5_TICKET_ENC_PART2 1\n";
126+
print O"#define HAVE_KRB5_FREE_UNPARSED_NAME 1\n";
126127
print O"#define PG_KRB_SRVNAM\"postgres\"\n";
127128
}
128129
if (my$port =$self->{options}->{"--with-pgport"})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp