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
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.213.2.3 2006/05/21 20:06:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.213.2.4 2010/03/03 20:31:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
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:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.116.2.4 2004/11/17 19:54:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.116.2.5 2010/03/03 20:31:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
int line_number = 1;
char *buf;
- while (!feof(file))
+ while (!feof(file) && !ferror(file))
{
buf = next_token_expand(file);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.263.2.6 2007/07/23 18:10:13 mha Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.263.2.7 2010/03/03 20:31:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (fp == NULL)
return NULL;
- while (!feof(fp))
+ while (!feof(fp) && !ferror(fp))
{
char *t = buf,
*ret;