qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [sheepdog] [PATCH v4 2/2] sheepdog: support user-define


From: MORITA Kazutaka
Subject: Re: [Qemu-devel] [sheepdog] [PATCH v4 2/2] sheepdog: support user-defined redundancy option
Date: Fri, 01 Nov 2013 23:20:04 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/22.1 Mule/5.0 (SAKAKI)

At Thu, 31 Oct 2013 13:49:28 +0800,
Liu Yuan wrote:
> 
> +/*
> + * Sheepdog support two kinds of redundancy, full replication and erasure
> + * coding.
> + *
> + * # create a fully replicated vdi with x copies
> + * -o redundancy=x (1 <= x <= SD_MAX_COPIES)
> + *
> + * # create a erasure coded vdi with x data strips and y parity strips
> + * -o redundancy=x:y (x must be one of {2,4,8,16} and 1 <= y < 
> SD_EC_MAX_STRIP)
> + */
> +static int parse_redundancy(BDRVSheepdogState *s, const char *opt)
> +{
> +    struct SheepdogInode *inode = &s->inode;
> +    const char *n1, *n2;
> +    uint8_t copy, parity;
> +    char p[10];
> +
> +    strncpy(p, opt, sizeof(p));

strncpy() is not safe here.  Please use pstrcpy() instead.

> +    n1 = strtok(p, ":");
> +    n2 = strtok(NULL, ":");
> +
> +    if ((n1 && !is_numeric(n1)) || (n2 && !is_numeric(n2))) {
> +        return -EINVAL;
> +    }

This cannot detect an error when 'opt' is empty.  Actually, the
following command causes a segfault.

 $ qemu-img create -o redundancy= sheepdog:test 4G

Thanks,

Kazutaka



reply via email to

[Prev in Thread] Current Thread [Next in Thread]