From 36616a34407a116a594548afdc1c055a0751ddfa Mon Sep 17 00:00:00 2001 From: William Brown Date: Tue, 5 Jan 2016 08:26:46 +1000 Subject: [PATCH] Ticket 48398 - Coverity defect 13352 - Resource leak in auditlog.c Bug Description: config_get_auditfaillog allocates a char* ptr and returns it. This if statement doesn't free that. Fix Description: Create a new char* variable to allocate the result of config_get_auditfaillog into, and then ensure we free it after we are done. https://fedorahosted.org/389/ticket/48398 Author: wibrown Review by: ??? --- ldap/servers/slapd/auditlog.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ldap/servers/slapd/auditlog.c b/ldap/servers/slapd/auditlog.c index 45ef16e..d61ea3e 100644 --- a/ldap/servers/slapd/auditlog.c +++ b/ldap/servers/slapd/auditlog.c @@ -91,6 +91,7 @@ write_auditfail_log_entry( Slapi_PBlock *pb ) int flag = 0; Operation *op; int pbrc = 0; + char *auditfail_config = NULL; /* if the audit log is not enabled, just skip all of this stuff */ @@ -129,13 +130,17 @@ write_auditfail_log_entry( Slapi_PBlock *pb ) curtime = current_time(); /* log the raw, unnormalized DN */ dn = slapi_sdn_get_udn(sdn); - if (config_get_auditfaillog() == NULL || strlen(config_get_auditfaillog()) == 0) { + auditfail_config = config_get_auditfaillog(); + if (auditfail_config == NULL || strlen(auditfail_config) == 0) { /* If no auditfail log write to audit log */ write_audit_file(SLAPD_AUDIT_LOG, operation_get_type(op), dn, change, flag, curtime, pbrc); } else { /* If we have our own auditfail log path */ write_audit_file(SLAPD_AUDITFAIL_LOG, operation_get_type(op), dn, change, flag, curtime, pbrc); } + if (auditfail_config != NULL) { + slapi_ch_free_string(&auditfail_config); + } } -- 2.5.0