Commit b58d8c9a authored by Tom Lane's avatar Tom Lane

Don't putenv() a string that is allocated in a context that will go away

soon.  I suspect this explains bug #3902, though I'm still not able to
reproduce that.
parent 65b39ec3
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.162 2008/01/01 19:45:49 momjian Exp $ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.163 2008/01/30 04:11:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -384,7 +384,6 @@ pg_GSS_recvauth(Port *port) ...@@ -384,7 +384,6 @@ pg_GSS_recvauth(Port *port)
min_stat, min_stat,
lmin_s, lmin_s,
gflags; gflags;
char *kt_path;
int mtype; int mtype;
int ret; int ret;
StringInfoData buf; StringInfoData buf;
...@@ -398,11 +397,19 @@ pg_GSS_recvauth(Port *port) ...@@ -398,11 +397,19 @@ pg_GSS_recvauth(Port *port)
* setenv("KRB5_KTNAME", pg_krb_server_keyfile, 0); except setenv() * setenv("KRB5_KTNAME", pg_krb_server_keyfile, 0); except setenv()
* not always available. * not always available.
*/ */
if (!getenv("KRB5_KTNAME")) if (getenv("KRB5_KTNAME") == NULL)
{ {
kt_path = palloc(MAXPGPATH + 13); size_t kt_len = strlen(pg_krb_server_keyfile) + 14;
snprintf(kt_path, MAXPGPATH + 13, char *kt_path = malloc(kt_len);
"KRB5_KTNAME=%s", pg_krb_server_keyfile);
if (!kt_path)
{
ereport(LOG,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return STATUS_ERROR;
}
snprintf(kt_path, kt_len, "KRB5_KTNAME=%s", pg_krb_server_keyfile);
putenv(kt_path); putenv(kt_path);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment