[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Heimdal PATCH] LDAP backend support for OpenLDAP 2.1.x



On Thu, 2003-05-29 at 06:59, Luke Howard wrote:
> 
> There's another, subtle bug in the LDAP backend that Andrew Bartlett
> of the SAMBA team discovered: storing HDBFlags as an integer is both
> compiler and byte-order dependent.
> 
> -- Luke

Sorry; I don't catch the problem very well. Those the heimdal
implementation of HDBFlags2int and int2HDBFlags are buggy?

Cause I patched the hdb-ldap.c with this code but I',m not sure if I got
back to the same problem. :-(






--- heimdal-0.6/lib/hdb/hdb-ldap.c	2003-06-09 17:34:24.000000000 -0500
+++ heimdal-0.6-work/lib/hdb/hdb-ldap.c	2003-06-09 17:26:20.000000000 -0500
@@ -421,12 +421,10 @@
 	}
     }
 
-    memset(&oflags, 0, sizeof(oflags));
-    memcpy(&oflags, &orig.flags, sizeof(HDBFlags));
-    memset(&nflags, 0, sizeof(nflags));
-    memcpy(&nflags, &ent->flags, sizeof(HDBFlags));
+    oflags=HDBFlags2int(orig.flags);
+    nflags=HDBFlags2int(ent->flags);
 
-    if (memcmp(&oflags, &nflags, sizeof(HDBFlags))) {
+    if ( oflags != nflags ){
 	rc = asprintf(&tmp, "%lu", nflags);
 	if (rc < 0) {
 	    krb5_set_error_string(context, "asprintf: out of memory");
@@ -801,7 +799,8 @@
     } else {
 	tmp = 0;
     }
-    memcpy(&ent->flags, &tmp, sizeof(HDBFlags));
+
+    ent->flags = int2HDBFlags(tmp);
 
     values = ldap_get_values((LDAP *) db->db, msg, "krb5EncryptionType");
     if (values != NULL) {