This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/4977] SEGV in strlen() of string argument of vsnprintf call on RHEL WS3/64-bit
- From: "timp at pulsic dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 29 Aug 2007 16:34:04 -0000
- Subject: [Bug libc/4977] SEGV in strlen() of string argument of vsnprintf call on RHEL WS3/64-bit
- References: <20070829152853.4977.timp@pulsic.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From timp at pulsic dot com 2007-08-29 16:34 -------
(In reply to comment #3)
> Passing it once to some function is just fine. What your testcase does
> wrong is passing the same va_list object to another function, while the standards
> say that if you pass it to some function and that function uses va_arg on it,
> then the object can be only passed to va_end, nothing else.
> On some architectures it can work even multiple times,
yep - that's what I was alluding too - poor language on my part
> that's mainly
> architectures which define va_list as a pointer (e.g. i386), but note
> that doing so is highly unportable.
indeed - it's one thing that I hadn't fully appreciated until now
> On other architectures, va_list as is
> a one element array containing some structure (e.g. x86_64). If you pass
> that to some function, you just pass its address to it, the object actually
> resides in the function which invoked va_start or va_copy, if their argument
> is an automatic va_list variable. So, the first vsnprintf will modify that
> va_list object to point after all arguments it consumed and when you call
> vsnprintf again with the same va_list (== the same address of some automatic
> struct), it will start looking at garbage.
ah - I've just realised that I missed the requirement for the va_end after the
first vsnprintf() from my reading of the specification - thanks for the
clarification. As with many things, now that it's been pointed out to me, it
does seem obvious :)
I sit enlightened.
Cheers Jakub
Tim
--
http://sourceware.org/bugzilla/show_bug.cgi?id=4977
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.