diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2011-03-15 16:03:47 +0800 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2011-06-03 18:44:14 +0200 |
commit | 7a244f7d2c1f405729a647f205314f3b14f4468f (patch) | |
tree | 383660b6c392a837cead9a794bd2fb6532fcc0fc | |
parent | 1d13581b9c08146c24d95168a53695187128ca35 (diff) | |
download | klibc-7a244f7d2c1f405729a647f205314f3b14f4468f.tar.gz |
[klibc] [DEBUG] Use va_copy when reusing a va_list
When tracing (with the DEBUG compile-time option set to 1 or 2),
exverror calls TRACEV to print its arguments before passing them on.
So the arguments are consumed by the time exvwarning looks for them,
resulting in a segfault:
$ sh -c '"'
sh: Syntax error: Unterminated quoted string
$ sh -o debug -c '"'
sh: Segmentation fault (core dumped)
Make a copy with va_copy to avoid this.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/dash/error.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/usr/dash/error.c b/usr/dash/error.c index 7ad73bca6bf18..9d31989ee8cb8 100644 --- a/usr/dash/error.c +++ b/usr/dash/error.c @@ -143,8 +143,11 @@ exverror(int cond, const char *msg, va_list ap) { #ifdef DEBUG if (msg) { + va_list aq; TRACE(("exverror(%d, \"", cond)); - TRACEV((msg, ap)); + va_copy(aq, ap); + TRACEV((msg, aq)); + va_end(aq); TRACE(("\") pid=%d\n", getpid())); } else TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid())); |