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.)
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*lines = *line_nums = NIL;
- while (!feof(file))
+ while (!feof(file) && !ferror(file))
{
buf = next_token_expand(filename, file);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
if (fp == NULL)
return NULL;
- while (!feof(fp))
+ while (!feof(fp) && !ferror(fp))
{
char *t = buf,
*ret;