ldap/servers/slapd/attrsyntax.c | 6 +++--- ldap/servers/slapd/dn.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)
New commits: commit 3e170da37a4f8a15b1342430cc2a912bb8b99872 Author: Nathan Kinder nkinder@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 ba30871..6d3fe8c 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 227a41e..8e0d0fa 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -572,6 +572,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; @@ -592,6 +593,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; @@ -612,6 +614,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;
389-commits@lists.fedoraproject.org