[libvirt] [PATCH] storage: add check for invalid volume name

Eric Blake eblake at redhat.com
Fri Apr 11 04:28:39 UTC 2014


On 04/10/2014 10:02 PM, Jincheng Miao wrote:
> If volume name is a path, storageVolCreateXML appends that name to
> the specified pool path, that will taint other pools. Adding the
> volume check is better for sanity.
> 
> Signed-off-by: Jincheng Miao <jmiao at redhat.com>
> ---
>  src/storage/storage_driver.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 

>  
> +    /* Make sure the volume name is not a path */
> +    if (last_component(newvol->name) != newvol->name) {

Why not just:

if (strchr(newvol->name, '/'))

Also, shouldn't we forbid things like "." and ".." as the newvol name?

> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("storage volume name '%s' is a path"),

I don't like the word "path" in a user-facing error message for anything
other than a list of directory names separated by colon; better would be
a message such as "requested storage volume name '%s' cannot contain /"
or "requested storage volume name '%s' not permitted".

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list