Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b52dc7

Browse files
committed
Repair postmaster memory leakage during password authentication.
1 parent6aa0821 commit6b52dc7

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

‎src/backend/libpq/crypt.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Dec 17, 1997 - Todd A. Brandys
1010
*Orignal Version Completed.
1111
*
12-
* $Id: crypt.c,v 1.29 2000/08/27 21:50:18 tgl Exp $
12+
* $Id: crypt.c,v 1.30 2001/02/07 23:31:38 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -30,8 +30,11 @@
3030
char**pwd_cache=NULL;
3131
intpwd_cache_count=0;
3232

33-
/*-------------------------------------------------------------------------*/
34-
33+
/*
34+
* crypt_getpwdfilename --- get name of password file
35+
*
36+
* Note that result string is palloc'd, and should be freed by the caller.
37+
*/
3538
char*
3639
crypt_getpwdfilename(void)
3740
{
@@ -45,8 +48,11 @@ crypt_getpwdfilename(void)
4548
returnpfnam;
4649
}
4750

48-
/*-------------------------------------------------------------------------*/
49-
51+
/*
52+
* crypt_getpwdreloadfilename --- get name of password-reload-needed flag file
53+
*
54+
* Note that result string is palloc'd, and should be freed by the caller.
55+
*/
5056
char*
5157
crypt_getpwdreloadfilename(void)
5258
{
@@ -58,6 +64,7 @@ crypt_getpwdreloadfilename(void)
5864
bufsize=strlen(pwdfilename)+strlen(CRYPT_PWD_RELOAD_SUFX)+1;
5965
rpfnam= (char*)palloc(bufsize);
6066
snprintf(rpfnam,bufsize,"%s%s",pwdfilename,CRYPT_PWD_RELOAD_SUFX);
67+
pfree(pwdfilename);
6168

6269
returnrpfnam;
6370
}
@@ -77,6 +84,8 @@ crypt_openpwdfile(void)
7784
fprintf(stderr,"Couldn't read %s: %s\n",
7885
filename,strerror(errno));
7986

87+
pfree(filename);
88+
8089
returnpwdfile;
8190
}
8291

@@ -119,22 +128,22 @@ compar_user(const void *user_a, const void *user_b)
119128
staticvoid
120129
crypt_loadpwdfile(void)
121130
{
122-
123131
char*filename;
124132
intresult;
125133
FILE*pwd_file;
126134
charbuffer[256];
127135

128136
filename=crypt_getpwdreloadfilename();
129137
result=unlink(filename);
138+
pfree(filename);
130139

131140
/*
132141
* We want to delete the flag file before reading the contents of the
133142
* pg_pwd file. If result == 0 then the unlink of the reload file was
134143
* successful. This means that a backend performed a COPY of the
135144
* pg_shadow file to pg_pwd. Therefore we must now do a reload.
136145
*/
137-
if (!pwd_cache||!result)
146+
if (!pwd_cache||result==0)
138147
{
139148
if (pwd_cache)
140149
{/* free the old data only if this is a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp