ldap/servers/slapd/attrsyntax.c | 6 +++---
ldap/servers/slapd/dn.c | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
New commits:
commit 4da627a74d756ab627863de6f52dc663d58fb2d2
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Dec 16 08:02:46 2010 -0800
Bug 663597 - Memory leaks in normalization code
The DN normalization code uses a Slapi_Attr on the stack to avoid
allocation of the struct. The contents of the Slapi_Attr are
never freed. This patch ensure that the struct is cleared out
properly.
There was also a leak in the syntax normalization code where a
pointer to recently allocated string could get overwritten without
freeing the string first. This patch frees the string first.
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 456f830..1c77f4a 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -469,14 +469,14 @@ char *
slapi_attr_syntax_normalize( const char *s )
{
struct asyntaxinfo *asi = NULL;
- char *r;
-
+ char *r = NULL;
- if((asi=attr_syntax_get_by_name(s)) != NULL ) {
+ if((asi=attr_syntax_get_by_name(s)) != NULL ) {
r = slapi_ch_strdup(asi->asi_name);
attr_syntax_return( asi );
}
if ( NULL == asi ) {
+ slapi_ch_free_string( &r );
r = attr_syntax_normalize_no_lookup( s );
}
return r;
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 914712a..1912f70 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -576,6 +576,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t
*dest_len)
slapi_attr_init(&test_attr, typestart);
is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
+ attr_done(&test_attr);
/* Reset the character we modified. */
*d = savechar;
@@ -596,6 +597,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t
*dest_len)
slapi_attr_init(&test_attr, typestart);
is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
+ attr_done(&test_attr);
/* Reset the character we modified. */
*d = savechar;
@@ -616,6 +618,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t
*dest_len)
slapi_attr_init(&test_attr, typestart);
is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
+ attr_done(&test_attr);
/* Reset the character we modified. */
*d = savechar;
Show replies by date