Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d831990

Browse files
committed
verify_password() leaked a file descriptor if it failed to find the given
userid in the flat password file. Do it enough times and the postmaster panicked :-(
1 parent 90e0b66 commit d831990

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/backend/libpq/password.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1994, Regents of the University of California
33
*
4-
* $Id: password.c,v 1.26 1999/10/23 03:13:21 tgl Exp $
4+
* $Id: password.c,v 1.27 1999/11/23 01:04:38 tgl Exp $
55
*
66
*/
77

@@ -45,6 +45,8 @@ verify_password(char *auth_arg, char *user, char *password)
4545
return STATUS_ERROR;
4646
}
4747

48+
pfree(pw_file_fullname);
49+
4850
while (!feof(pw_file))
4951
{
5052
char pw_file_line[255],
@@ -67,15 +69,12 @@ verify_password(char *auth_arg, char *user, char *password)
6769

6870
if (strcmp(user, test_user) == 0)
6971
{
70-
/* we're outta here one way or the other. */
72+
/* we're outta here one way or the other, so close file */
7173
FreeFile(pw_file);
7274

7375
if (strcmp(crypt(password, test_pw), test_pw) == 0)
7476
{
7577
/* it matched. */
76-
77-
pfree(pw_file_fullname);
78-
7978
return STATUS_OK;
8079
}
8180

@@ -85,19 +84,17 @@ verify_password(char *auth_arg, char *user, char *password)
8584
fputs(PQerrormsg, stderr);
8685
pqdebug("%s", PQerrormsg);
8786

88-
pfree(pw_file_fullname);
89-
9087
return STATUS_ERROR;
9188
}
9289
}
9390

91+
FreeFile(pw_file);
92+
9493
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
9594
"verify_password: user '%s' not found in password file.\n",
9695
user);
9796
fputs(PQerrormsg, stderr);
9897
pqdebug("%s", PQerrormsg);
9998

100-
pfree(pw_file_fullname);
101-
10299
return STATUS_ERROR;
103100
}

0 commit comments

Comments
 (0)