From: Jonathan Nieder <jrnieder@gmail.com>
To: dash@vger.kernel.org
Subject: [PATCH] [DEBUG] Use va_copy when we use va_list twice
Date: Sun, 13 Mar 2011 11:33:25 -0500 [thread overview]
Message-ID: <20110313163259.GA24451@elie> (raw)
When tracing (if the DEBUG compile-time option was set to 1 or 2),
exverror calls TRACEV to print its arguments before passing them on to
exvwarning. That consumes the arguments, resulting in a segfault:
$ sh -c '"'
sh: Syntax error: Unterminated quoted string
$ sh -o debug -c '"'
sh: Segmentation fault (core dumped)
Making a copy with va_copy fixes it.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Ran into this while tracking down a potential ifs leak from
<http://bugs.debian.org/618023>.
src/error.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/error.c b/src/error.c
index f1a358d..e51d827 100644
--- a/src/error.c
+++ b/src/error.c
@@ -143,8 +143,10 @@ exverror(int cond, const char *msg, va_list ap)
{
#ifdef DEBUG
if (msg) {
+ va_list aq;
+ va_copy(aq, ap);
TRACE(("exverror(%d, \"", cond));
- TRACEV((msg, ap));
+ TRACEV((msg, aq));
TRACE(("\") pid=%d\n", getpid()));
} else
TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
--
1.7.4.1
next reply other threads:[~2011-03-13 16:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-13 16:33 Jonathan Nieder [this message]
2011-03-14 6:29 ` [PATCH v2] [DEBUG] Use va_copy when reusing a va_list Jonathan Nieder
2011-03-15 8:04 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110313163259.GA24451@elie \
--to=jrnieder@gmail.com \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox