[29540] in CVS-changelog-for-Kerberos-V5
krb5 commit: Fix memory leak in db2 policy DB initialization
daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed Aug 10 13:51:36 2016
Date: Wed, 10 Aug 2016 13:51:32 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201608101751.u7AHpWMR009230@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu
https://github.com/krb5/krb5/commit/f53160634dd5de41c12701ade9e59d4b4dcd645b
commit f53160634dd5de41c12701ade9e59d4b4dcd645b
Author: Greg Hudson <ghudson@mit.edu>
Date: Fri Jun 24 12:33:05 2016 -0400
Fix memory leak in db2 policy DB initialization
osa_adb_init_db() maintains a static linked list mapping filenames to
lock structures. Entries are never removed from the list; when their
reference counts hit 0, the lockfile is closed but the filename
remains allocated. However, the filename is allocated each time the
lockfile is re-opened, leaking the old value. Fix this leak by moving
filename initialization to entry creation.
ticket: 8432 (new)
target_version: 1.14-next
tags: pullup
src/plugins/kdb/db2/adb_openclose.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/plugins/kdb/db2/adb_openclose.c b/src/plugins/kdb/db2/adb_openclose.c
index d9d4cee..7db30a3 100644
--- a/src/plugins/kdb/db2/adb_openclose.c
+++ b/src/plugins/kdb/db2/adb_openclose.c
@@ -131,6 +131,12 @@ osa_adb_init_db(osa_adb_db_t *dbp, char *filename, char *lockfilename,
return ENOMEM;
}
memset(lockp, 0, sizeof(*lockp));
+ lockp->lockinfo.filename = strdup(lockfilename);
+ if (lockp->lockinfo.filename == NULL) {
+ free(lockp);
+ free(db);
+ return ENOMEM;
+ }
lockp->next = locklist;
locklist = lockp;
}
@@ -146,7 +152,6 @@ osa_adb_init_db(osa_adb_db_t *dbp, char *filename, char *lockfilename,
* needs be open read/write so that write locking can work with
* POSIX systems
*/
- lockp->lockinfo.filename = strdup(lockfilename);
if ((lockp->lockinfo.lockfile = fopen(lockfilename, "r+")) == NULL) {
/*
* maybe someone took away write permission so we could only
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5