diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-03-03 20:31:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-03-03 20:31:41 +0000 |
commit | 1b8fe53c79f9b9b411733047de2a7a809b506591 (patch) | |
tree | e1456afa6495cb61f0a94f04311072cf6e242bd0 /src | |
parent | a15fa97a18642db487b1176384e27a281976c950 (diff) | |
download | postgresql-1b8fe53c79f9b9b411733047de2a7a809b506591.tar.gz postgresql-1b8fe53c79f9b9b411733047de2a7a809b506591.zip |
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.)
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/copy.c | 4 | ||||
-rw-r--r-- | src/backend/libpq/hba.c | 4 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 44077a3fb29..b48e5b93f5a 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.236.4.3 2006/05/21 20:06:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.236.4.4 2010/03/03 20:31:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -393,7 +393,7 @@ CopyGetData(void *databuf, int datasize) { case COPY_FILE: fread(databuf, datasize, 1, copy_file); - if (feof(copy_file)) + if (feof(copy_file) || ferror(copy_file)) fe_eof = true; break; case COPY_OLD_FE: diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 73f2bd548b2..0c5c0e5bcfe 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.136.4.1 2005/06/21 01:23:25 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.136.4.2 2010/03/03 20:31:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -400,7 +400,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 1c766a68ed3..e18a59d8e7e 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.301.4.6 2007/07/23 18:12:56 mha Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.301.4.7 2010/03/03 20:31:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3276,7 +3276,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; |