Managing DNs in libads only in utf8

simo idra at samba.org
Tue Feb 27 14:25:56 GMT 2007


On Tue, 2007-02-27 at 15:25 +0100, Volker Lendecke wrote:
> On Tue, Feb 27, 2007 at 09:13:41AM -0500, simo wrote:
> > smb_utf8_dn *utf8_dn_talloc(TALLOC_CTX *ctx, char *utf8_dn) {
> > 
> > 	smb_utf8_dn *a_dn;
> > 	int len = strlen(utf8_dn);
> > 
> > 	a_dn = talloc(sizeof(smb_utf8_dn) + len + 1);
> > 	if (a_dn == NULL) return NULL;
> > 
> > 	a_dn->dn = (char *)(&a_dn[1]);
> > 	memcopy(a_dn->dn, utf8_dn, len + 1);
> > 
> > 	return a_dn;
> > }
> > 
> > Do you see any problem with this?
> > We keep one allocation.
> 
> One unnecessary pointer, and I would suspect that this is
> even less defined behaviour. But that's a detail.

The difference is that if you do b_dn = a_dn at least you get something
consistent in this case. With char[1] I guess you get simply a truncated
string. But it is a detail, and we should never assign it that way in
any case.
If char[] is valid and is C99 can we use it? Or are we still trying not
to require C99 in samba3 ?

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org



More information about the samba-technical mailing list