From: Guido Günther Date: Tue, 18 Oct 2011 07:07:41 +0000 (+0200) Subject: virBufferEscapeShell: Fix escaping of single quotes. X-Git-Tag: v0.9.7-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94f776e71673c9666b883f2a93b152a66057aa80;p=thirdparty%2Flibvirt.git virBufferEscapeShell: Fix escaping of single quotes. When checking if we need to escape a single quote we were looking at the character after the quote instead of at the quote itself. --- diff --git a/src/util/buf.c b/src/util/buf.c index 34347b5dd5..f582cd2227 100644 --- a/src/util/buf.c +++ b/src/util/buf.c @@ -524,13 +524,13 @@ virBufferEscapeShell(virBufferPtr buf, const char *str) *out++ = '\''; while (*cur != 0) { - *out++ = *cur++; if (*cur == '\'') { + *out++ = '\''; /* Replace literal ' with a close ', a \', and a open ' */ *out++ = '\\'; *out++ = '\''; - *out++ = '\''; } + *out++ = *cur++; } *out++ = '\''; *out = 0;