ctdb debug vasprintf memory overwrite in ib

Peter Somogyi psomogyi at gamax.hu
Fri Apr 20 16:05:29 GMT 2007


> >    ret = vsnprintf(NULL, 0, format, tmp_ap);
>
> Note that you can't rely on this returning the number of characters
> that would have been output if the buffer were large enough until C99
> or UNIX98 IIRC.

I've just found another solution: I've just changed my bzr to use 
talloc_vasprintf:

void do_debug(const char *format, ...)
...
        va_start(ap, format);
        s = talloc_vasprintf(NULL, format, ap);
        va_end(ap);
...
        talloc_free(s);

And now it seems to work fine, and I don't have to worry about va_copy 
compatibility any more... (talloc does it...)

[+ hopefully my bzr commits should be visible on samba-cvs soon...]

Peter


More information about the samba-technical mailing list