1 --- postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c.orig 2008-03-01 00:31:42.000000000 +0100
2 +++ postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c 2008-03-20 22:59:22.658133220 +0100
8 + char portstr[32], sockstr[MAXPGPATH];
11 - char connstr[128]; /* Should be way more than enough! */
12 + char connstr[128+MAXPGPATH]; /* Should be way more than enough! */
15 + *portstr = *sockstr = '\0';
18 * Look in post_opts for a -p switch.
20 strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr)));
21 /* keep looking, maybe there is another -p */
23 + } else if (strncmp(p, "-k", strlen("-k")) == 0)
26 + /* advance past whitespace/quoting */
27 + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
29 + /* find end of value (not including any ending quote!) */
32 + !(isspace((unsigned char) *q) || *q == '\'' || *q == '"'))
34 + /* and save the argument value */
35 + strlcpy(sockstr, p, Min(q - p + 1, sizeof(sockstr)));
36 + /* keep looking, maybe there is another -k */
39 /* Advance to next whitespace */
40 while (*p && !isspace((unsigned char) *p))
42 * This parsing code isn't amazingly bright either, but it should be
43 * okay for valid port settings.
46 + if (!*portstr || !*sockstr)
52 while (isspace((unsigned char) *p))
54 - if (strncmp(p, "port", 4) != 0)
56 + if (!strncmp(p, "port", 4)) {
58 while (isspace((unsigned char) *p))
61 /* and save the argument value */
62 strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr)));
63 /* keep looking, maybe there is another */
64 + } else if(!strncmp(p, "unix_socket_directory", 21)) {
66 + while (isspace((unsigned char) *p))
71 + /* advance past any whitespace/quoting */
72 + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
74 + /* find end of value (not including any ending quote/comment!) */
77 + !(isspace((unsigned char) *q) ||
78 + *q == '\'' || *q == '"' || *q == '#'))
80 + /* and save the argument value */
81 + strlcpy(sockstr, p, Min((q - p) + 1, sizeof(sockstr)));
82 + /* keep looking, maybe there is another */
88 * probably timeout first
90 snprintf(connstr, sizeof(connstr),
91 - "dbname=postgres port=%s connect_timeout=5", portstr);
92 + "dbname=postgres port=%s connect_timeout=5%s%s", portstr,
93 + (*sockstr ? " host=" : ""), sockstr);
95 for (i = 0; i < wait_seconds; i++)