From: Jeff Cody <jcody@redhat.com>
To: qemu-block@nongnu.org
Cc: peter.maydell@linaro.org, jcody@redhat.com,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PULL for-2.9 3/3] block/curl: Check protocol prefix
Date: Fri, 31 Mar 2017 21:25:08 -0400 [thread overview]
Message-ID: <20170401012508.24665-4-jcody@redhat.com> (raw)
In-Reply-To: <20170401012508.24665-1-jcody@redhat.com>
From: Max Reitz <mreitz@redhat.com>
If the user has explicitly specified a block driver and thus a protocol,
we have to make sure the URL's protocol prefix matches. Otherwise the
latter will silently override the former which might catch some users by
surprise.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20170331120431.1767-3-mreitz@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
block/curl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/curl.c b/block/curl.c
index 34dbd33..2708d57 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -659,6 +659,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
const char *cookie;
double d;
const char *secretid;
+ const char *protocol_delimiter;
static int inited = 0;
@@ -700,6 +701,15 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
goto out_noclean;
}
+ if (!strstart(file, bs->drv->protocol_name, &protocol_delimiter) ||
+ !strstart(protocol_delimiter, "://", NULL))
+ {
+ error_setg(errp, "%s curl driver cannot handle the URL '%s' (does not "
+ "start with '%s://')", bs->drv->protocol_name, file,
+ bs->drv->protocol_name);
+ goto out_noclean;
+ }
+
s->username = g_strdup(qemu_opt_get(opts, CURL_BLOCK_OPT_USERNAME));
secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PASSWORD_SECRET);
--
2.9.3
next prev parent reply other threads:[~2017-04-01 1:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 1:25 [Qemu-devel] [PULL for-2.9 0/3] Block patches Jeff Cody
2017-04-01 1:25 ` [Qemu-devel] [PULL for-2.9 1/3] rbd: Fix regression in legacy key/values containing escaped : Jeff Cody
2017-04-01 1:25 ` [Qemu-devel] [PULL for-2.9 2/3] qapi/curl: Extend and fix blockdev-add schema Jeff Cody
2017-04-01 1:25 ` Jeff Cody [this message]
2017-04-03 10:15 ` [Qemu-devel] [PULL for-2.9 0/3] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170401012508.24665-4-jcody@redhat.com \
--to=jcody@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).