Răsfoiți Sursa

Ticket #47773 - mem leak in do_bind when there is an error

https://fedorahosted.org/389/ticket/47773
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Do not get the SLAPI_BIND_TARGET_SDN from the pblock and
free it in the clean up code if it was never set in the pblock - just free
the local variable sdn in this case.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 11 ani în urmă
părinte
comite
2a57b521b8
1 a modificat fișierele cu 5 adăugiri și 1 ștergeri
  1. 5 1
      ldap/servers/slapd/bind.c

+ 5 - 1
ldap/servers/slapd/bind.c

@@ -131,6 +131,7 @@ do_bind( Slapi_PBlock *pb )
     ber_tag_t ber_rc;
     int rc = 0;
     Slapi_DN *sdn = NULL;
+    int bind_sdn_in_pb = 0; /* is sdn set in the pb? */
     Slapi_Entry *referral;
     char errorbuf[BUFSIZ];
     char **supported, **pmech;
@@ -369,6 +370,7 @@ do_bind( Slapi_PBlock *pb )
     isroot = slapi_dn_isroot( slapi_sdn_get_ndn(sdn) );
     slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
     slapi_pblock_set( pb, SLAPI_BIND_TARGET_SDN, (void*)sdn );
+    bind_sdn_in_pb = 1; /* pb now owns sdn */
     slapi_pblock_set( pb, SLAPI_BIND_METHOD, &method );
     slapi_pblock_set( pb, SLAPI_BIND_SASLMECHANISM, saslmech );
     slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, &cred );
@@ -861,7 +863,9 @@ account_locked:
 free_and_return:;
     if (be)
         slapi_be_Unlock(be);
-    slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn);
+    if (bind_sdn_in_pb) {
+	    slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn);
+    }
     slapi_sdn_free(&sdn);
     slapi_ch_free_string( &saslmech );
     slapi_ch_free( (void **)&cred.bv_val );