[Libguestfs] [PATCH 2/3] New API: part-get-name (RHBZ#593511).

Richard W.M. Jones rjones at redhat.com
Tue Feb 4 15:59:36 UTC 2014


On Tue, Feb 04, 2014 at 04:01:32PM +0100, Pino Toscano wrote:
> +static char *
> +extract_optionally_quoted (const char *value)
> +{
> +  size_t value_len = strlen (value);
> +
> +  if (value_len >= 2 &&
> +      ((value[0] == '\'' && value[value_len - 1] == '\'') ||
> +       (value[0] == '"' && value[value_len - 1] == '"'))) {
> +    value_len -= 2;
> +    ++value;
> +  }
> +
> +  char *ret = strndup (value, value_len);
> +  if (ret == NULL) {
> +    reply_with_perror ("strndup");
> +    return NULL;
> +  }
> +
> +  return ret;
> +}

My spidey sense asks what happens if the value contains quote
characters?  I wonder if sgdisk escapes them.

Rest of the patch looks fine, but I think you should try setting the
partition name to a few weird values and see what sgdisk does.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list