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 */
3030char * * pwd_cache = NULL ;
3131int pwd_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+ */
3538char *
3639crypt_getpwdfilename (void )
3740{
@@ -45,8 +48,11 @@ crypt_getpwdfilename(void)
4548 return pfnam ;
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+ */
5056char *
5157crypt_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 return rpfnam ;
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 return pwdfile ;
8190}
8291
@@ -119,22 +128,22 @@ compar_user(const void *user_a, const void *user_b)
119128static void
120129crypt_loadpwdfile (void )
121130{
122-
123131 char * filename ;
124132 int result ;
125133 FILE * pwd_file ;
126134 char buffer [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