qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.9?] block/nfs: Do not strcmp(


From: Peter Maydell
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH for-2.9?] block/nfs: Do not strcmp() with NULL
Date: Tue, 11 Apr 2017 14:30:36 +0100

On 11 April 2017 at 14:13, Max Reitz <address@hidden> wrote:
> Parsing the URI is not required to give us a scheme; uri->scheme may be
> NULL.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  block/nfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/nfs.c b/block/nfs.c
> index 0816678307..0c7d5619fe 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -83,7 +83,7 @@ static int nfs_parse_uri(const char *filename, QDict 
> *options, Error **errp)
>          error_setg(errp, "Invalid URI specified");
>          goto out;
>      }
> -    if (strcmp(uri->scheme, "nfs") != 0) {
> +    if (!uri->scheme || strcmp(uri->scheme, "nfs") != 0) {
>          error_setg(errp, "URI scheme must be 'nfs'");
>          goto out;
>      }

Just as a record of IRC discussion, a lot of the callers of uri_parse()
get this wrong; for instance
 qemu-img info -f nbd blub#://
 qemu-img info -f sheepdog blub#://
both segfault. So since this isn't new (2.8 behaved the same way) I think
we should not try to fix this at this point in the 2.9 release cycle.
For 2.10 we might consider whether there's a change we could make to
the uri_parse() API that makes this mistake less easy. (For instance
do any of the users really ever want to handle a relative URL without
a schema?)

thanks
-- PMM



reply via email to

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