Skip to content

Commit f749b4c

Browse files
committed
Pay attention to fgets() failure return.
1 parent 92fd384 commit f749b4c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/libpq/password.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
33
* Portions Copyright (c) 1994, Regents of the University of California
44
*
5-
* $Id: password.c,v 1.32 2000/08/27 21:50:18 tgl Exp $
5+
* $Id: password.c,v 1.33 2000/11/27 03:43:49 tgl Exp $
66
*
77
*/
88

@@ -56,9 +56,11 @@ verify_password(const Port *port, const char *user, const char *password)
5656
*test_user,
5757
*test_pw;
5858

59-
fgets(pw_file_line, sizeof(pw_file_line), pw_file);
59+
if (fgets(pw_file_line, sizeof(pw_file_line), pw_file) == NULL)
60+
pw_file_line[0] = '\0';
6061
/* kill the newline */
61-
if (pw_file_line[strlen(pw_file_line) - 1] == '\n')
62+
if (strlen(pw_file_line) > 0 &&
63+
pw_file_line[strlen(pw_file_line) - 1] == '\n')
6264
pw_file_line[strlen(pw_file_line) - 1] = '\0';
6365

6466
p = pw_file_line;

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