Re: [Libguestfs] [PATCH 5/7] perl: Properly decode node names, value keys from UTF-8

Richard W.M. Jones
Mon, 13 Jan 2014 13:23:09 -0000

On Sat, Jan 11, 2014 at 12:12:50AM +0100, Hilko Bengen
wrote:
> ---
>  generator/generator.ml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/generator/generator.ml b/generator/generator.ml
> index 6b1eef7..4119b04 100755
> --- a/generator/generator.ml
> +++ b/generator/generator.ml
> @@ -2648,7 +2648,7 @@ DESTROY (h)
>               pr "        croak (\"%%s: %%s\",
\"%s\", strerror (errno));\n"
>  	       name;
>               if f_len_exists name then
> -               pr "      RETVAL = newSVpvn (r, hivex_%s_len
(%s));\n"
> +               pr "      RETVAL = newSVpvn_utf8 (r, hivex_%s_len
(%s), 1);\n"
>                   name (String.concat ", " c_params)
>               else
>                 pr "      RETVAL = newSVpv (r, 0);\n";
> --
> 1.8.5.2
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs@redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs

ACK.

I wonder what happens if the registry contains a garbage string (one
which is not valid utf-8)?  It looks from the source as if
newSVpvn_utf8 just sets a flag in the SV, so that would be OK in the
sense that Perl programs wouldn't start crashing.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.