[PATCH] fix for ldb_msg_add_string() to increase value lifetime
simo
idra at samba.org
Tue Sep 4 12:37:13 GMT 2007
On Tue, 2007-09-04 at 15:14 +1000, Tim Potter wrote:
> On Mon, 2007-09-03 at 21:48 +1000, Andrew Bartlett wrote:
> > On Mon, 2007-09-03 at 21:35 +1000, Tim Potter wrote:
> > > Hey ldb people - I would like to propose this patch to take a copy of
> > > the string value when calling ldb_msg_add_string(). It's actually
> > > pretty easy to find garbage in your attribute values if the lifetime of
> > > the const char *str parameter is less than the lifetime of the
> > > ldb_message.
> > >
> > > Comments? It looks OK to me. (-:
> >
> > The main problem is that much of the current code assumes the current
> > lifetime semantics, and we don't want too much copies of the string
> > around 'just in case'. We should also watch for failures of the memory
> > allocation.
>
> Good point about the memory allocation failure. I'll update the patch.
>
> However it's hardly keeping an extra copy "just in case". It's keeping
> an extra copy to avoid data corruption or crashes! I think some extra
> memory is worth the price of ensuring correctness.
+1
Simo.
--
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org
More information about the samba-technical
mailing list