]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virBufferEscapeShell: Fix escaping of single quotes.
authorGuido Günther <agx@sigxcpu.org>
Tue, 18 Oct 2011 07:07:41 +0000 (09:07 +0200)
committerGuido Günther <agx@sigxcpu.org>
Tue, 18 Oct 2011 15:03:36 +0000 (17:03 +0200)
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.

src/util/buf.c

index 34347b5dd5c43e287956f8d71e139e178d94b899..f582cd222749eaab7ec40cbfa39da010886e536e 100644 (file)
@@ -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;