Core dump of net -- fix to ldap.c

Ken Cross kcross at nssolutions.com
Sat Jan 18 14:54:01 GMT 2003


I've been having a problem with net crashing in SAMBA_3_0 and OpenLDAP
2.0.27:

 assertion "entry != NULL" failed: file "getvalues.c", line 93, function
"ldap_get_values_len"
 Abort trap (core dumped)

I traced the problem to the ads_set_machine_sd routine in ldap.c.  It
wasn't checking the return from ads_first_entry, which was returning a
NULL in my tests.

Here's the fix.  LDAP_NO_RESULTS_RETURNED may not be the best error
code, but it's descriptive.


# cvs diff -pu ldap.c
Index: ldap.c
===================================================================
RCS file: /cvsroot/samba/source/libads/ldap.c,v
retrieving revision 1.55.2.13
diff -p -u -r1.55.2.13 ldap.c
--- ldap.c      3 Jan 2003 08:28:02 -0000       1.55.2.13
+++ ldap.c      18 Jan 2003 14:44:33 -0000
@@ -1430,6 +1430,11 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT
        if (!ADS_ERR_OK(ret)) return ret;
 
        msg   = ads_first_entry(ads, res);
+        if (!msg) {   /* KJC */
+                ret = ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
+               goto ads_set_sd_error;
+       }
+
        ads_pull_sid(ads, msg, attrs[1], &sid); 
        if (!(ctx = talloc_init("sec_io_desc"))) {
                ret =  ADS_ERROR(LDAP_NO_MEMORY);


Ken




More information about the samba-technical mailing list