From 8e789e8ef16968bc04a6c1bf57a6a9cd4ed945b3 Mon Sep 17 00:00:00 2001
From: "Marc G. Fournier" <scrappy@hub.org>
Date: Thu, 29 Jan 1998 03:24:36 +0000
Subject: [PATCH] From: Phil Thompson <phil@river-bank.demon.co.uk>

Attached is the patch to fix the warning messages from my code.  I also
fixed one which wasn't my code.  Apart from the usual warnings about the
bison/yacc generated code I only have one other warning message.  This
is in gramm.y around line 2234.  I wasn't sure of the fix.

I've also replaced all the calls to free() in gramm.y to calls to
pfree().  Without these I was getting backend crashes with GRANT.  This
might already have been fixed.
---
 src/backend/libpq/auth.c            | 105 ++++++++++++++--------------
 src/backend/utils/cache/lsyscache.c |   4 +-
 src/backend/utils/init/postinit.c   |   4 +-
 src/interfaces/libpq/fe-auth.c      |   4 +-
 src/interfaces/libpq/fe-auth.h      |   4 +-
 src/interfaces/libpq/fe-connect.c   |   6 +-
 src/interfaces/libpq/fe-connect.h   |   4 +-
 7 files changed, 66 insertions(+), 65 deletions(-)

diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 58c60112e1c..b0891e4c5f2 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.23 1998/01/27 03:24:54 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.24 1998/01/29 03:23:05 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -390,9 +390,6 @@ void auth_failed(Port *port)
  */
 void be_recvauth(Port *port)
 {
-	AuthRequest areq;
-	void (*auth_handler)();
-
 	/*
 	 * Get the authentication method to use for this frontend/database
 	 * combination.
@@ -400,70 +397,76 @@ void be_recvauth(Port *port)
 
 	if (hba_getauthmethod(&port->raddr, port->database, port->auth_arg,
 				&port->auth_method) != STATUS_OK)
-	{
 		PacketSendError(&port->pktInfo, "Missing or mis-configured pg_hba.conf file");
-		return;
-	}
 
-	/* Handle old style authentication. */
-
-	if (PG_PROTOCOL_MAJOR(port->proto) == 0)
+	else if (PG_PROTOCOL_MAJOR(port->proto) == 0)
 	{
+		/* Handle old style authentication. */
+
 		if (old_be_recvauth(port) != STATUS_OK)
 			auth_failed(port);
-
-		return;
 	}
-
-	/* Handle new style authentication. */
-
-	switch (port->auth_method)
+	else
 	{
-	case uaReject:
-		auth_failed(port);
-		return;
- 
-	case uaKrb4:
-		areq = AUTH_REQ_KRB4;
-		auth_handler = handle_krb4_auth;
-		break;
+		AuthRequest areq;
+		void (*auth_handler)();
 
-	case uaKrb5:
-		areq = AUTH_REQ_KRB5;
-		auth_handler = handle_krb5_auth;
-		break;
+		/* Keep the compiler quiet. */
 
-	case uaTrust:
 		areq = AUTH_REQ_OK;
-		auth_handler = handle_done_auth;
-		break;
 
-	case uaIdent:
-		if (authident(&port->raddr.in, &port->laddr.in, port->user,
-				port->auth_arg) != STATUS_OK)
+		/* Handle new style authentication. */
+
+		auth_handler = NULL;
+
+		switch (port->auth_method)
 		{
-			auth_failed(port);
-			return;
-		}
+		case uaReject:
+			break;
+ 
+		case uaKrb4:
+			areq = AUTH_REQ_KRB4;
+			auth_handler = handle_krb4_auth;
+			break;
 
-		areq = AUTH_REQ_OK;
-		auth_handler = handle_done_auth;
-		break;
+		case uaKrb5:
+			areq = AUTH_REQ_KRB5;
+			auth_handler = handle_krb5_auth;
+			break;
 
-	case uaPassword:
-		areq = AUTH_REQ_PASSWORD;
-		auth_handler = handle_password_auth;
-		break;
+		case uaTrust:
+			areq = AUTH_REQ_OK;
+			auth_handler = handle_done_auth;
+			break;
 
-	case uaCrypt:
-		areq = AUTH_REQ_CRYPT;
-		auth_handler = handle_password_auth;
-		break;
- 	}
+		case uaIdent:
+			if (authident(&port->raddr.in, &port->laddr.in,
+				port->user, port->auth_arg) == STATUS_OK)
+			{
+				areq = AUTH_REQ_OK;
+				auth_handler = handle_done_auth;
+			}
+
+			break;
 
-	/* Tell the frontend what we want next. */
+		case uaPassword:
+			areq = AUTH_REQ_PASSWORD;
+			auth_handler = handle_password_auth;
+			break;
 
-	sendAuthRequest(port, areq, auth_handler);
+		case uaCrypt:
+			areq = AUTH_REQ_CRYPT;
+			auth_handler = handle_password_auth;
+			break;
+ 		}
+
+		/* Tell the frontend what we want next. */
+
+		if (auth_handler != NULL)
+			sendAuthRequest(port, areq, auth_handler);
+		else
+			auth_failed(port);
+	}
 }
  
 
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 2a37ad0fe7b..8b0a7784a79 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.10 1998/01/20 05:04:32 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.11 1998/01/29 03:23:09 scrappy Exp $
  *
  * NOTES
  *	  Eventually, the index information should go through here, too.
@@ -173,7 +173,7 @@ get_atttypmod(Oid relid, AttrNumber attnum)
 							 0, 0))
 		return att_tup.atttypmod;
 	else
-		return NULL;
+		return -1;
 }
 
 /*				---------- INDEX CACHE ----------						 */
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 7a7e0719467..e3ec4131be4 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.21 1997/12/20 00:10:47 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.22 1998/01/29 03:23:28 scrappy Exp $
  *
  * NOTES
  *		InitPostgres() is the function called from PostgresMain
@@ -66,7 +66,7 @@
 #include "catalog/catname.h"
 #include "catalog/pg_database.h"
 
-#include "libpq/libpq-be.h"
+#include "libpq/libpq.h"
 
 static void VerifySystemDatabase(void);
 static void VerifyMyDatabase(void);
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 7f25afcb38e..7f77589a6b9 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.13 1998/01/26 01:42:25 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.14 1998/01/29 03:24:03 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -477,7 +477,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
  */
 int
 fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
-		  const char *password, const char *PQerrormsg)
+		  const char *password, char *PQerrormsg)
 {
 	switch (areq)
 	{
diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h
index e4676fcd97b..ebbca5dfb3e 100644
--- a/src/interfaces/libpq/fe-auth.h
+++ b/src/interfaces/libpq/fe-auth.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: fe-auth.h,v 1.7 1998/01/26 01:42:26 scrappy Exp $
+ * $Id: fe-auth.h,v 1.8 1998/01/29 03:24:21 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,7 +33,7 @@
 
 extern int
 fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
-			const char *password, const char *PQerromsg);
+			const char *password, char *PQerromsg);
 extern void fe_setauthsvc(const char *name, char *PQerrormsg);
 
 #define PG_KRB4_VERSION "PGVER4.1"		/* at most KRB_SENDAUTH_VLEN chars */
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 3ac229c5a82..bc7d3b3b200 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.60 1998/01/28 03:42:27 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.61 1998/01/29 03:24:30 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -808,9 +808,7 @@ PQreset(PGconn *conn)
  * SIDE_EFFECTS: may block.
 */
 int
-packetSend(PGconn *conn,
-		   char *buf,
-		   size_t len)
+packetSend(PGconn *conn, const char *buf, size_t len)
 {
 	/* Send the total packet size. */
 
diff --git a/src/interfaces/libpq/fe-connect.h b/src/interfaces/libpq/fe-connect.h
index 999ae05dac4..53c9d8e2881 100644
--- a/src/interfaces/libpq/fe-connect.h
+++ b/src/interfaces/libpq/fe-connect.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: fe-connect.h,v 1.6 1998/01/26 01:42:30 scrappy Exp $
+ * $Id: fe-connect.h,v 1.7 1998/01/29 03:24:36 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,6 +23,6 @@
  *----------------------------------------------------------------
  */
 
-int packetSend(PGconn *conn, char *buf, size_t len);
+int packetSend(PGconn *conn, const char *buf, size_t len);
 
 #endif							/* FE_CONNECT_H */
-- 
GitLab