[Xorp-cvs] XORP cvs commit: xorp/libxorp
Atanu Ghosh
atanu@ICSI.Berkeley.EDU
Tue, 20 Dec 2005 23:45:35 -0800
Hi,
It looks like the problem only occurs on xorp13 the AMD64 machine.
Atanu.
>>>>> "Atanu" == Atanu Ghosh <atanu@ICSI.Berkeley.EDU> writes:
Atanu> The function x_vasprintf takes printf style arguments
Atanu> (varargs) and returns a malloc'd buffer with all the
Atanu> output. Internally this function starts with a buffer of size
Atanu> 1025, it then calls vsnprintf with the buffer. If the buffer
Atanu> is not large enough a new buffer is allocated and a second
Atanu> try is made to format the arguments. The problem is that in
Atanu> the second and subsequent calls to vnsprintf the varargs
Atanu> pointer is in the wrong place. I therefore used va_copy to
Atanu> pass the same varargs pointer to vsnprintf every time.
Atanu> I saw the problem when tracing BGP an update message packed
Atanu> with NLRIs required a buffer of 21060 bytes. The vsnprintf
Atanu> routine ends up accessing parts of that stack that it
Atanu> shouldn't.
Atanu> I should have guessed that va_copy was new. I'll fix the
Atanu> problem in x_asprintf.
Atanu> Atanu.
>>>>> "Pavlin" == Pavlin Radoslavov <pavlin@icir.org> writes:
>>> CVSROOT: /usr/local/www/data/cvs Module name: xorp Changes by:
>>> atanu@xorpc.icir.org 2005-12-21 01:24:47 UTC
>>>
>>> XORP CVS repository
>>>
>>>
>>> Modified files: libxorp xlog.c
>>>
>>> Log message: Take a copy of the variable arguments so they can
>>> be used multiple times.
Pavlin> Introducing va_copy() breaks the compilation on FreeBSD-4.10
Pavlin> with the default compiler (gcc-2.95.4):
Pavlin> xlog.c: In function `x_vasprintf': xlog.c:1162: warning:
Pavlin> implicit declaration of function `va_copy' gmake[3]: ***
Pavlin> [xlog.lo] Error 1
Pavlin> Can you give an example where the original implementation
Pavlin> fails.
Pavlin> Pavlin
>>> Also fix a possible double free issue which could never happen.
>>>
>>> Revision Changes Path 1.13 +5 -2; commitid: af7343a8aede7ea6;
>>> xorp/libxorp/xlog.c
>>> _______________________________________________ Xorp-cvs mailing
>>> list Xorp-cvs@icir.org
>>> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-cvs
Atanu> _______________________________________________ Xorp-cvs
Atanu> mailing list Xorp-cvs@icir.org
Atanu> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-cvs