]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/slapi_utils.c
Do not return pointers into BerElement we do not own
[openldap] / servers / slapd / slapi / slapi_utils.c
index 47c6aca9390a41e15e73bdb94113577e3f6868ba..702042fbc773f9a1b16401af162c3149e1e6247d 100644 (file)
@@ -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 */
@@ -3192,7 +3204,7 @@ LDAPMod **slapi_x_modifications2ldapmods(Modifications **pmodlist)
 Modifications *slapi_x_ldapmods2modifications (LDAPMod **mods)
 {
 #ifdef LDAP_SLAPI
-       Modifications *modlist, **modtail;
+       Modifications *modlist = NULL, **modtail;
        LDAPMod **modp;
 
        modtail = &modlist;