From 3b5f98723ca0b807f382c2a7be0113f3b3afe99e Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 1 Apr 2003 17:16:56 +0000 Subject: [PATCH] Fix crasher in slapi_dn_issuffix() when malformed DNs are passed --- servers/slapd/slapi/slapi_utils.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 47c6aca939..8a6b604caf 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -902,6 +902,7 @@ slapi_dn_issuffix( #ifdef LDAP_SLAPI struct berval bdn, ndn; struct berval bsuffix, nsuffix; + int rc; assert( dn != NULL ); assert( suffix != NULL ); @@ -912,10 +913,21 @@ slapi_dn_issuffix( bsuffix.bv_val = suffix; bsuffix.bv_len = strlen( suffix ); - dnNormalize2( NULL, &bdn, &ndn ); - dnNormalize2( NULL, &bsuffix, &nsuffix ); + if ( dnNormalize2( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) { + return 0; + } + + if ( dnNormalize2( NULL, &bsuffix, &nsuffix ) != LDAP_SUCCESS ) { + slapi_ch_free( (void **)&ndn.bv_val ); + return 0; + } + + rc = dnIsSuffix( &ndn, &nsuffix ); - return dnIsSuffix( &ndn, &nsuffix ); + slapi_ch_free( (void **)&ndn.bv_val ); + slapi_ch_free( (void **)&nsuffix.bv_val ); + + return rc; #else /* LDAP_SLAPI */ return 0; #endif /* LDAP_SLAPI */ -- 2.39.5