Skip to content

Commit 61d7511

Browse files
committed
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.)
1 parent eb1c3b5 commit 61d7511

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/backend/libpq/hba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.199 2010/03/01 16:02:01 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.200 2010/03/03 20:31:08 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -404,7 +404,7 @@ tokenize_file(const char *filename, FILE *file,
404404

405405
*lines = *line_nums = NIL;
406406

407-
while (!feof(file))
407+
while (!feof(file) && !ferror(file))
408408
{
409409
buf = next_token_expand(filename, file);
410410

src/interfaces/libpq/fe-connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.388 2010/02/26 02:01:32 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.389 2010/03/03 20:31:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -4394,7 +4394,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
43944394
if (fp == NULL)
43954395
return NULL;
43964396

4397-
while (!feof(fp))
4397+
while (!feof(fp) && !ferror(fp))
43984398
{
43994399
char *t = buf,
44004400
*ret;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy