Fix off-by-1 bug in pg_ctl in -D handling, per report from [email protected]
authorNeil Conway <[email protected]>
Mon, 6 Dec 2004 01:09:20 +0000 (01:09 +0000)
committerNeil Conway <[email protected]>
Mon, 6 Dec 2004 01:09:20 +0000 (01:09 +0000)
src/bin/pg_ctl/pg_ctl.c

index c647930134cb2562fb3472c1817ae161b3b9680e..427432806564dd531497f2f80918d489901dc5b3 100644 (file)
@@ -1289,10 +1289,10 @@ main(int argc, char **argv)
                        {
                                case 'D':
                                        {
-                                               char       *pgdata_D = xmalloc(strlen(optarg));
+                                               char       *pgdata_D;
                                                char       *env_var = xmalloc(strlen(optarg) + 8);
 
-                                               strcpy(pgdata_D, optarg);
+                                               pgdata_D = xstrdup(optarg);
                                                canonicalize_path(pgdata_D);
                                                snprintf(env_var, strlen(optarg) + 8, "PGDATA=%s",
                                                                 pgdata_D);