File dhcp-4.2.4-ldap-0005-memleak-fix-in-ldap_read_config.patch of Package dhcp.openSUSE_12.1_Update
From 98c770187f29389e94873712e13108cc5d44cf89 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Mon, 10 Dec 2012 09:56:00 +0100
References: bnc#788787
Upstream: sent [ISC-Bugs #32217]
Subject: [PATCH] Fixed memory leaks in ldap read config error handling
Fixed to free ldap results before bailing out when the
dhcpServer object or it's dhcpService references can't
be parsed / resolved.
---
server/ldap.c | 15 +++++++++++----
1 Datei geändert, 11 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
diff --git a/server/ldap.c b/server/ldap.c
index fb7b504..2f6e1c6 100644
--- a/server/ldap.c
+++ b/server/ldap.c
@@ -475,11 +475,14 @@ ldap_parse_host (struct ldap_config_stack *item, struct parse *cfile)
x_parser_strcat (cfile, tempbv[0]->bv_val);
x_parser_strcat (cfile, " {\n");
- if (hwaddr != NULL && hwaddr[0] != NULL)
+ if (hwaddr != NULL)
{
- x_parser_strcat (cfile, "hardware ");
- x_parser_strcat (cfile, hwaddr[0]->bv_val);
- x_parser_strcat (cfile, ";\n");
+ if (hwaddr[0] != NULL)
+ {
+ x_parser_strcat (cfile, "hardware ");
+ x_parser_strcat (cfile, hwaddr[0]->bv_val);
+ x_parser_strcat (cfile, ";\n");
+ }
ldap_value_free_len (hwaddr);
}
@@ -2090,6 +2093,8 @@ ldap_read_config (void)
res = ldap_parse_entry_options(hostent, cfile, NULL);
if (res != ISC_R_SUCCESS)
{
+ ldap_value_free_len (tempbv);
+ ldap_msgfree (hostres);
ldap_memfree (hostdn);
ldap_stop();
x_parser_free(&cfile);
@@ -2102,6 +2107,8 @@ ldap_read_config (void)
if (res != ISC_R_SUCCESS)
{
log_error ("LDAP: cannot parse dhcpServer entry '%s'", hostdn);
+ ldap_value_free_len (tempbv);
+ ldap_msgfree (hostres);
ldap_memfree (hostdn);
ldap_stop();
x_parser_free(&cfile);
--
1.7.10.4