diff options
author | Tom Lane | 2010-03-03 20:31:34 +0000 |
---|---|---|
committer | Tom Lane | 2010-03-03 20:31:34 +0000 |
commit | 14669da788122b2d948ca7700bdb99877e4d2dc0 (patch) | |
tree | 5103c1eb8f2ac3626455796075a9855c59220e13 | |
parent | 238e6b9519956c0234992ff29ba5d9c321476c94 (diff) |
Fix a couple of places that would loop forever if attempts to read a stdio file
set ferror() but never set feof(). This is known to be the case for recent
glibc when trying to read a directory as a file, and might be true for other
platforms/cases too. Per report from Ed L. (There is more that we ought to
do about his report, but this is one easily identifiable issue.)
-rw-r--r-- | src/backend/libpq/hba.c | 4 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index b7209536085..a8f1bd36067 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.149 2005/10/17 16:24:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.149.2.1 2010/03/03 20:31:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -413,7 +413,7 @@ tokenize_file(const char *filename, FILE *file, *lines = *line_nums = NIL; - while (!feof(file)) + while (!feof(file) && !ferror(file)) { buf = next_token_expand(filename, file); diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 51e312d5e0b..9fd782e6013 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.323.2.4 2007/10/09 15:03:30 mha Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.323.2.5 2010/03/03 20:31:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3146,7 +3146,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username) if (fp == NULL) return NULL; - while (!feof(fp)) + while (!feof(fp) && !ferror(fp)) { char *t = buf, *ret; |