diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-02 02:40:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-02 02:40:52 +0000 |
commit | 040f28b4b096b34f3e7bc62121a7be347bcebbc3 (patch) | |
tree | a44371ac9bab32cb473be0f7ab8c3d7cd1280c87 /src/bin/pg_ctl/pg_ctl.c | |
parent | 794e3e81a0e8068de2606015352c1254cb071a78 (diff) |
Fix pg_ctl's readfile() to not go into infinite loop on an empty file
(could happen if either postgresql.conf or postmaster.opts is empty).
It's been broken since the C version was written for 8.0, so patch
all the way back.
initdb's copy of the function is broken in the same way, but it's
less important there since the input files should never be empty.
Patch that in HEAD only, and also fix some cosmetic differences that
crept into that copy of the function.
Per report from Corry Haines and Jeff Davis.
Diffstat (limited to 'src/bin/pg_ctl/pg_ctl.c')
-rw-r--r-- | src/bin/pg_ctl/pg_ctl.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index ff8f4a25523..ba8a17f4e14 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.112 2009/08/27 16:59:38 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.113 2009/09/02 02:40:52 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -292,7 +292,7 @@ static char ** readfile(const char *path) { FILE *infile; - int maxlength = 0, + int maxlength = 1, linelen = 0; int nlines = 0; char **result; |