aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-03-11 03:08:37 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-03-11 03:08:37 +0000
commita71daab4b465c4701489dd992005c65ca8604584 (patch)
tree02ac5d760dacf002cc2db8134f37a7b4e4870c26 /src/interfaces/libpq/fe-auth.c
parent773e84f52a57e3d1d2d4c98c6f49925b7c47b4ac (diff)
downloadpostgresql-a71daab4b465c4701489dd992005c65ca8604584.tar.gz
postgresql-a71daab4b465c4701489dd992005c65ca8604584.zip
Change PQconndefaults() to return a malloc'd array, instead of a static
array. This allows processing of conninfo strings to be made thread-safe, at the cost of a small memory leak in applications that use PQconndefaults() and are not updated to free the returned array via the new PQconninfoFree() function. But PQconndefaults() is probably not used very much, so this seems like a good compromise.
Diffstat (limited to 'src/interfaces/libpq/fe-auth.c')
-rw-r--r--src/interfaces/libpq/fe-auth.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 7a3bff45e92..fe870963df4 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
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.37 2000/02/07 23:10:08 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.38 2000/03/11 03:08:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,7 +75,7 @@ struct authsvc
* allowed. Unauthenticated connections are disallowed unless there
* isn't any authentication system.
*/
-static struct authsvc authsvcs[] = {
+static const struct authsvc authsvcs[] = {
#ifdef KRB4
{"krb4", STARTUP_KRB4_MSG, 1},
{"kerberos", STARTUP_KRB4_MSG, 1},
@@ -94,7 +94,7 @@ static struct authsvc authsvcs[] = {
{"password", STARTUP_PASSWORD_MSG, 0}
};
-static int n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
+static const int n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
#ifdef KRB4
/*----------------------------------------------------------------
@@ -549,7 +549,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
*
* Set/return the authentication service currently selected for use by the
* frontend. (You can only use one in the frontend, obviously.)
+ *
+ * NB: This is not thread-safe if different threads try to select different
+ * authentication services! It's OK for fe_getauthsvc to select the default,
+ * since that will be the same for all threads, but direct application use
+ * of fe_setauthsvc is not thread-safe. However, use of fe_setauthsvc is
+ * deprecated anyway...
*/
+
static int pg_authsvc = -1;
void
@@ -558,7 +565,7 @@ fe_setauthsvc(const char *name, char *PQerrormsg)
int i;
for (i = 0; i < n_authsvcs; ++i)
- if (!strcmp(name, authsvcs[i].name))
+ if (strcmp(name, authsvcs[i].name) == 0)
{
pg_authsvc = i;
break;