diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-02 02:41:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-02 02:41:13 +0000 |
commit | bbc2e9a606a91558cd467ac7e5cfcc23d279ec0e (patch) | |
tree | 6a5c0efa2c6f5252774de5c1e892156adb5e1adc | |
parent | 1146b2fd9dcde785de9ceff6ce473568d9663a54 (diff) | |
download | postgresql-bbc2e9a606a91558cd467ac7e5cfcc23d279ec0e.tar.gz postgresql-bbc2e9a606a91558cd467ac7e5cfcc23d279ec0e.zip |
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.
-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 5385a4d2bbb..1ed2d2ab800 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-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.74.2.6 2008/09/30 13:14:15 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.74.2.7 2009/09/02 02:41:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -288,7 +288,7 @@ static char ** readfile(const char *path) { FILE *infile; - int maxlength = 0, + int maxlength = 1, linelen = 0; int nlines = 0; char **result; |