Unable to map attributeID

simo idra at samba.org
Mon Aug 24 04:53:41 MDT 2009


On Mon, 2009-08-24 at 13:03 +1000, Andrew Bartlett wrote:
> On Sun, 2009-08-23 at 22:32 +1000, Andrew Bartlett wrote:
> > On Sat, 2009-08-22 at 15:42 +0400, Matthieu Patou wrote:
> > > Hello all,
> > > 
> > > in my tries to create an script to upgrade provision I am a blocked when 
> > > I try to create missing attributes in the schema.ldb:
> > > 
> > > schema_fsmo_add: failed to map attributeID[1.2.840.113556.1.4.767-FP]: 
> > > WERR_INVALID_PARAM
> > 
> > In the C code that generates that message, replace all instances of
> > printf("%s", foo->data) with printf("%*.s", foo->length, foo->data)
> > 
> > Then find all the instances where we do something like:
> > 
> > char *foo_str = foo->data
> > 
> > and replace with 
> > 
> > char *foo_str talloc_strndup(ctx, foo->data, foo->length)
> > 
> > (or any other similar construction to ensure we respect the length of
> > the input). 
> > 
> > The python bindings now take the LDB interface at their word, and only
> > supply the length-limited string, without a NULL terminator.  As such,
> > we are not finding bugs in all the code that assumed that there is
> > always a NULL terminator at the end of a ->data in a struct ldb_val.
> 
> The bug here is that schema_fsmo.c call samdb_result_string().  This
> does the evil cast - but fixing it would imply having it duplicate every
> string ever returned from LDB.  
> 
> This might be harder to fix than I hoped :-(

I would rather make it documented (and change the code accordingly) that
data is always 1 byte longer than length when the content is a string
and that byte is NULL.

We could make it true for any value not just strings, and have ldb_val
functions check the last +1 byte is NULL.

The convenience it provides when parsing strings is totally worth the
extra byte imho.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list