[libvirt] [PATCH 1/3] virBufferEscapeShell: Emit quotes for the empty string

Make the empty string return '' to match cmdEcho's behavior. --- src/util/buf.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/util/buf.c b/src/util/buf.c index f582cd2..b7fcf6d 100644 --- a/src/util/buf.c +++ b/src/util/buf.c @@ -507,15 +507,20 @@ virBufferEscapeShell(virBufferPtr buf, const char *str) return; /* Only quote if str includes shell metacharacters. */ - if (!strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) { + if (*str && !strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) { virBufferAdd(buf, str, -1); return; } - len = strlen(str); - if (xalloc_oversized(4, len) || - VIR_ALLOC_N(escaped, 4 * len + 3) < 0) { - virBufferSetError(buf); + if (*str) { + len = strlen(str); + if (xalloc_oversized(4, len) || + VIR_ALLOC_N(escaped, 4 * len + 3) < 0) { + virBufferSetError(buf); + return; + } + } else { + virBufferAdd(buf, "''", 2); return; } -- 1.7.6.3

On 10/18/2011 01:35 PM, Guido Günther wrote:
Make the empty string return '' to match cmdEcho's behavior. --- src/util/buf.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, Oct 18, 2011 at 02:09:55PM -0600, Eric Blake wrote:
On 10/18/2011 01:35 PM, Guido Günther wrote:
Make the empty string return '' to match cmdEcho's behavior. --- src/util/buf.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
ACK. Pushed the whole series. Thanks! -- Guido
participants (2)
-
Eric Blake
-
Guido Günther