]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix pg_ctl's readfile() to not go into infinite loop on an empty file
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Sep 2009 02:41:27 +0000 (02:41 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Sep 2009 02:41:27 +0000 (02:41 +0000)
(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.

src/bin/pg_ctl/pg_ctl.c

index 6338c5859baa368576df9558e9908d4e70312ecd..d699513f074a51b90f40026c4a0418baf0d1b1ea 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.53.4.7 2008/09/30 13:14:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.53.4.8 2009/09/02 02:41:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -269,7 +269,7 @@ static char **
 readfile(const char *path)
 {
        FILE       *infile;
-       int                     maxlength = 0,
+       int                     maxlength = 1,
                                linelen = 0;
        int                     nlines = 0;
        char      **result;