From 9cab13c42e1f8535aac5feffcc896051ca6413d3 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sun, 14 Mar 1999 16:06:43 +0000
Subject: [PATCH]         I've been having also sorts of fun trying to get
 kerberos 4 authentifica tion working with postgresql-6.4.2 and  KTH-KRB
 Ebones (http://www.pdc.kth.se/kth-kr b) on a dec alpha running DU 4.0D using
 the native compiler. The following patch does the trick.

The rationale behind this is as follows. The KTH-KRB code header files
defines
lots of lengths like INST_SZ,REALM_SZ and KRB_SENDAUTH_VLEN. It also has
a
habit of doing things like

        chararray[LENGTH] = '\0'

to ensure null terminated strings. In my instance this just happens to
blat
the kerberos principal instance string leading to error like

        pg_krb4_recvauth: kerberos error: Can't decode authenticator
(krb_rd_req
)

The application code that comes with KTH-KRB uses "KRB_SENDAUTH_VLEN +
1" and
sometimes uses "INST_SZ + 1" so it seems safest to put that 1 char
buffer in
the appropriate place.


Rodney McDuff
---
 src/backend/libpq/auth.c       | 6 +++---
 src/interfaces/libpq/fe-auth.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 6adf2ee8b0b..7ef784e03d0 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.33 1999/02/13 23:15:38 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.34 1999/03/14 16:06:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -77,8 +77,8 @@ pg_krb4_recvauth(Port *port)
 {
 	long					krbopts = 0;	/* one-way authentication */
 	KTEXT_ST			clttkt;
-	char					instance[INST_SZ],
-								version[KRB_SENDAUTH_VLEN];
+	char					instance[INST_SZ+1],
+								version[KRB_SENDAUTH_VLEN+1];
 	AUTH_DAT			auth_data;
 	Key_schedule	key_sched;
 	int						status;
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 46d2290135c..99f273d2d23 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.26 1999/02/13 23:22:39 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.27 1999/03/14 16:06:43 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -144,8 +144,8 @@ pg_krb4_init()
 static char *
 pg_krb4_authname(char *PQerrormsg)
 {
-	char		instance[INST_SZ];
-	char		realm[REALM_SZ];
+	char		instance[INST_SZ+1];
+	char		realm[REALM_SZ+1];
 	int			status;
 	static char name[SNAME_SZ + 1] = "";
 
-- 
GitLab