[PATCH] [DEBUG] Use va_copy when we use va_list twice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux