[libvirt] [PATCH 1/3] util: Introduce virBufferEscapeSizedBuf

Peter Krempa pkrempa at redhat.com
Thu May 12 12:15:06 UTC 2016


On Thu, May 12, 2016 at 07:49:30 -0400, John Ferlan wrote:
> Soon we will need to escape a buffer string that cannot use strlen, so
> introduce this API to allow printing/escaping of the entire buffer.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virbuffer.c     | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/util/virbuffer.h     |  3 +++
>  3 files changed, 58 insertions(+)



> diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
> index d582e7d..6985832 100644
> --- a/src/util/virbuffer.c
> +++ b/src/util/virbuffer.c
> @@ -588,6 +588,60 @@ virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
>      VIR_FREE(escaped);
>  }
>  
> +
> +/**
> + * virBufferEscapeSizedString:

I don't think this makes much sense. If the string contains nul '\0'
bytes this won't help at all since it will copy the \0 byte to the
resulting string.

If the string doesn't contain those, then the previously existing code
would work just fine.

If you want to put such stuff to a commandline you need to encode it to
base 64 anyways.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160512/6d20e765/attachment-0001.sig>


More information about the libvir-list mailing list