1 --- postgresql-8.3.0/src/bin/pg_ctl/pg_ctl.c.orig 2008-01-01 20:45:55.000000000 +0100
2 +++ postgresql-8.3.0/src/bin/pg_ctl/pg_ctl.c 2008-02-19 21:30:21.369174813 +0100
8 + char portstr[32], sockstr[MAXPGPATH];
10 - char connstr[128]; /* Should be way more than enough! */
11 + char connstr[128+MAXPGPATH]; /* Should be way more than enough! */
14 + *portstr = *sockstr = '\0';
17 for (p = post_opts; *p;)
19 strlcpy(portstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1,
21 /* keep looking, maybe there is another -p */
22 + } else if (strncmp(p, "-k", strlen("-k")) == 0)
25 + /* advance past whitespace/quoting */
26 + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
28 + strlcpy(sockstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1,
30 + /* keep looking, maybe there is another -k */
32 /* Advance to next whitespace */
33 while (*p && !isspace((unsigned char) *p))
39 + if (!*portstr || !*sockstr)
45 while (isspace((unsigned char) *p))
47 - if (strncmp(p, "port", strlen("port")) != 0)
49 - p += strlen("port");
50 - while (isspace((unsigned char) *p))
51 + if (!strncmp(p, "port", strlen("port"))) {
52 + p += strlen("port");
53 + while (isspace((unsigned char) *p))
61 - while (isspace((unsigned char) *p))
62 + while (isspace((unsigned char) *p))
64 + strlcpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
66 + /* keep looking, maybe there is another */
67 + } else if(!strncmp(p, "unix_socket_directory", strlen("unix_socket_directory"))) {
68 + p += strlen("unix_socket_directory");
69 + while (isspace((unsigned char) *p))
74 - strlcpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
76 - /* keep looking, maybe there is another */
77 + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
79 + strlcpy(sockstr, p, Min(strcspn(p, "\"'#" WHITESPACE) + 1,
86 * probably timeout first
88 snprintf(connstr, sizeof(connstr),
89 - "dbname=postgres port=%s connect_timeout=5", portstr);
90 + "dbname=postgres port=%s connect_timeout=5%s%s", portstr,
91 + (*sockstr ? " host=" : ""), sockstr);
93 for (i = 0; i < wait_seconds; i++)