Skip to content

Commit 04f2403

Browse files
committed
Fix assign_pgstat_temp_directory() to ensure the directory path is
canonicalized. Avoid the need to elog(FATAL) on out-of-memory.
1 parent ac73ced commit 04f2403

File tree

1 file changed

+17
-8
lines changed
  • src/backend/utils/misc

1 file changed

+17
-8
lines changed

src/backend/utils/misc/guc.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.503 2009/04/23 00:23:45 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.504 2009/05/03 20:09:54 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -7618,19 +7618,28 @@ assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source)
76187618
{
76197619
if (doit)
76207620
{
7621+
char *canon_val = guc_strdup(ERROR, newval);
7622+
char *tname;
7623+
char *fname;
7624+
7625+
canonicalize_path(canon_val);
7626+
7627+
tname = guc_malloc(ERROR, strlen(canon_val) + 12); /* /pgstat.tmp */
7628+
sprintf(tname, "%s/pgstat.tmp", canon_val);
7629+
fname = guc_malloc(ERROR, strlen(canon_val) + 13); /* /pgstat.stat */
7630+
sprintf(fname, "%s/pgstat.stat", canon_val);
7631+
76217632
if (pgstat_stat_tmpname)
76227633
free(pgstat_stat_tmpname);
7634+
pgstat_stat_tmpname = tname;
76237635
if (pgstat_stat_filename)
76247636
free(pgstat_stat_filename);
7637+
pgstat_stat_filename = fname;
76257638

7626-
pgstat_stat_tmpname = guc_malloc(FATAL, strlen(newval) + 12); /* /pgstat.tmp */
7627-
pgstat_stat_filename = guc_malloc(FATAL, strlen(newval) + 13); /* /pgstat.stat */
7628-
7629-
sprintf(pgstat_stat_tmpname, "%s/pgstat.tmp", newval);
7630-
sprintf(pgstat_stat_filename, "%s/pgstat.stat", newval);
7639+
return canon_val;
76317640
}
7632-
7633-
return newval;
7641+
else
7642+
return newval;
76347643
}
76357644

76367645
#include "guc-file.c"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy