Commit b3f3092c authored by Neil Conway's avatar Neil Conway

Fix off-by-1 bug in pg_ctl in -D handling, per report from pjmodos@parba.cz

parent 29a26b25
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.48 2004/11/27 18:51:05 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.49 2004/12/06 01:09:20 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1289,10 +1289,10 @@ main(int argc, char **argv) ...@@ -1289,10 +1289,10 @@ main(int argc, char **argv)
{ {
case 'D': case 'D':
{ {
char *pgdata_D = xmalloc(strlen(optarg)); char *pgdata_D;
char *env_var = xmalloc(strlen(optarg) + 8); char *env_var = xmalloc(strlen(optarg) + 8);
strcpy(pgdata_D, optarg); pgdata_D = xstrdup(optarg);
canonicalize_path(pgdata_D); canonicalize_path(pgdata_D);
snprintf(env_var, strlen(optarg) + 8, "PGDATA=%s", snprintf(env_var, strlen(optarg) + 8, "PGDATA=%s",
pgdata_D); pgdata_D);
......
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