From: Levente Kurusa <lkurusa@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Levente Kurusa <lkurusa@redhat.com>, Fam Zheng <famz@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 2/3] block: vpc: introduce vpc_check_signature function
Date: Fri, 1 Aug 2014 15:40:00 +0200 [thread overview]
Message-ID: <1406900401-19550-3-git-send-email-lkurusa@redhat.com> (raw)
In-Reply-To: <1406900401-19550-1-git-send-email-lkurusa@redhat.com>
Check the signature in a helper function instead of in plain
code in order to avoid code duplication
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Levente Kurusa <lkurusa@redhat.com>
---
block/vpc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 2ba8fc2..a6a7213 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -156,11 +156,15 @@ static uint32_t vpc_checksum(uint8_t* buf, size_t size)
return ~res;
}
+static int vpc_check_signature(const void *buf)
+{
+ return !strncmp((char *)buf, "conectix", 8);
+}
static int vpc_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
const char *filename)
{
- if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
+ if (buf_size >= 8 && vpc_check_signature(buf))
return 100;
return 0;
}
@@ -184,7 +188,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
}
footer = (VHDFooter *) s->footer_buf;
- if (strncmp(footer->creator, "conectix", 8)) {
+ if (!vpc_check_signature(footer->creator)) {
int64_t offset = bdrv_getlength(bs->file);
if (offset < 0) {
ret = offset;
@@ -200,7 +204,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
if (ret < 0) {
goto fail;
}
- if (strncmp(footer->creator, "conectix", 8)) {
+ if (!vpc_check_signature(footer->creator)) {
error_setg(errp, "invalid VPC image");
ret = -EINVAL;
goto fail;
--
1.9.3
next prev parent reply other threads:[~2014-08-01 13:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 13:39 [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images Levente Kurusa
2014-08-01 13:39 ` [Qemu-devel] [PATCH 1/3] block: format: pass down the current state to the format's probe function Levente Kurusa
2014-08-01 13:40 ` Levente Kurusa [this message]
2014-08-01 13:40 ` [Qemu-devel] [PATCH 3/3] block: vpc: handle fixed size images in " Levente Kurusa
2014-08-12 13:20 ` [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images Stefan Hajnoczi
2014-08-12 13:35 ` Jeff Cody
2014-08-14 14:42 ` Levente Kurusa
2014-08-14 14:57 ` Jeff Cody
2014-08-15 10:55 ` Kevin Wolf
2014-08-15 11:21 ` Markus Armbruster
2014-08-15 12:28 ` Jeff Cody
2014-08-15 12:59 ` Markus Armbruster
2014-08-15 13:13 ` Eric Blake
2014-08-15 13:25 ` Jeff Cody
2014-08-15 12:14 ` Jeff Cody
2014-08-15 13:19 ` Eric Blake
2014-08-15 13:37 ` Kevin Wolf
2014-08-15 13:52 ` Jeff Cody
2014-08-15 14:00 ` Eric Blake
2014-08-15 14:10 ` Jeff Cody
2014-08-15 14:22 ` Eric Blake
2014-08-15 14:51 ` Jeff Cody
2014-08-15 14:42 ` Kevin Wolf
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=1406900401-19550-3-git-send-email-lkurusa@redhat.com \
--to=lkurusa@redhat.com \
--cc=drjones@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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).