浏览代码

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: mreynolds (Thanks!)
William Brown 10 年之前
父节点
当前提交
24c7896ec2
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      ldap/servers/slapd/auditlog.c

+ 4 - 1
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,15 @@ 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);
     }
+    slapi_ch_free_string(&auditfail_config);
 }