Bug in talloc_asprintf_append()
jra at samba.org
Thu Sep 13 16:38:25 GMT 2007
On Thu, Sep 13, 2007 at 09:40:28AM +0200, Stefan (metze) Metzmacher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> Jeremy Allison schrieb:
> > Tridge,
> > The talloc_asprintf_append() function doesn't take
> > into account a truncated string.
> Hi Jeremy,
> I think that's intentional, see:
> but I think it should be persistent between all string related
> talloc_*append* calls, talloc_append_string() was forgotten in
> the optimization.
It wasn't talloc_append_string() that caused the problem,
but the length calculation in talloc_asprintf_append().
I changed talloc_asprintf_append() to use strlen in the
length calculation, and now all my smbtorture tests pass
as talloc_asprintf_append() is doing what it's name would
suggest. If this gets reverted I'll have to remove all
use of talloc_asprintf_append() from the fileserving code,
as in it's original state it doesn't work with talloced
strings that have been truncated deliberately. I think
that's a bug as it's definately not what it's name
would suggest and violates the principle of least
suprises for the programmer.
More information about the samba-technical