[libvirt] [PATCH 6/6] xend: Escape reserved sexpr characters

Eric Blake eblake at redhat.com
Mon Nov 22 18:08:18 UTC 2010


On 11/22/2010 10:28 AM, Cole Robinson wrote:
> If we don't escape ' or \ xend can't parse the generated sexpr. This
> might over apply the EscapeSexpr routine, but it shouldn't hurt.
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  src/util/buf.c                             |   55 ++++++++++++++
>  src/util/buf.h                             |    1 +
>  src/xen/xend_internal.c                    |  112 +++++++++++++++------------
>  tests/xml2sexprdata/xml2sexpr-escape.sexpr |    1 +
>  tests/xml2sexprdata/xml2sexpr-escape.xml   |   24 ++++++
>  tests/xml2sexprtest.c                      |    1 +
>  6 files changed, 144 insertions(+), 50 deletions(-)
>  create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.sexpr
>  create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.xml

ACK series, with two nits:

You also need to update src/libvirt_private.syms:

diff --git i/src/libvirt_private.syms w/src/libvirt_private.syms
index 9ed05df..edbc4bc 100644
--- i/src/libvirt_private.syms
+++ w/src/libvirt_private.syms
@@ -23,6 +23,7 @@ virBufferAdd;
 virBufferAddChar;
 virBufferContentAndReset;
 virBufferError;
+virBufferEscapeSexpr;
 virBufferEscapeString;
 virBufferFreeAndReset;
 virBufferStrcat;


> @@ -5322,8 +5322,9 @@ xenDaemonFormatSxprChr(virDomainChrDefPtr def,
>          break;
>  
>      case VIR_DOMAIN_CHR_TYPE_UNIX:
> -        virBufferVSprintf(buf, "%s:%s%s", type,
> -                          def->data.nix.path,
> +        virBufferVSprintf(buf, "%s:", type);
> +        virBufferEscapeSexpr(buf, "%s", def->data.nix.path);
> +        virBufferVSprintf(buf, "%s",
>                            def->data.nix.listen ? ",server,nowait" : "");

Change that last line to:

if (def->data.nix.listen)
    virBufferAddLit(buf, ",server,nowait");

> +++ b/tests/xml2sexprdata/xml2sexpr-escape.xml
> @@ -0,0 +1,24 @@
> +<domain type='xen' id='15'>
> +  <name>fvtest</name>
> +  <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
> +  <os>
> +    <type>hvm</type>
> +    <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
> +    <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
> +    <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os&version="devel"  </cmdline>

Yep, definitely makes more sense for a use of '&' in a URL.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101122/58a42cac/attachment-0001.sig>


More information about the libvir-list mailing list