Skip to content

Commit e4cd186

Browse files
committed
Fix thinko in pg_read_file: testing for negative result is not the way
to determine whether fread() failed.
1 parent 6faa334 commit e4cd186

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/adt/genfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.7 2005/10/15 02:49:28 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.8 2005/10/15 19:47:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -134,7 +134,7 @@ pg_read_file(PG_FUNCTION_ARGS)
134134

135135
nbytes = fread(VARDATA(buf), 1, (size_t) bytes_to_read, file);
136136

137-
if (nbytes < 0)
137+
if (ferror(file))
138138
ereport(ERROR,
139139
(errcode_for_file_access(),
140140
errmsg("could not read file \"%s\": %m", filename)));

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