From: Max Reitz <mreitz@redhat.com>
To: Jeff Cody <jcody@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, mitake.hitoshi@lab.ntt.co.jp,
qemu-devel@nongnu.org, v.tolstov@selfip.ru, pbonzini@redhat.com,
namei.unix@gmail.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/1] block/sheepdog: fix argument passed to qemu_strtoul()
Date: Wed, 2 Mar 2016 16:27:31 +0100 [thread overview]
Message-ID: <56D70663.7030202@redhat.com> (raw)
In-Reply-To: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1661 bytes --]
On 02.03.2016 16:16, Jeff Cody wrote:
> The function qemu_strtoul() reads 'unsigned long' sized data,
> which is larger than uint32_t on 64-bit machines.
>
> Even though the snap_id field in the header is 32-bits, we must
> accomodate the full size in qemu_strtoul().
>
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> block/sheepdog.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index 8739acc..c6bf900 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -2543,7 +2543,7 @@ static int sd_snapshot_delete(BlockDriverState *bs,
> const char *name,
> Error **errp)
> {
> - uint32_t snap_id = 0;
> + unsigned long snap_id = 0;
> char snap_tag[SD_MAX_VDI_TAG_LEN];
> Error *local_err = NULL;
> int fd, ret;
> @@ -2565,12 +2565,12 @@ static int sd_snapshot_delete(BlockDriverState *bs,
> memset(buf, 0, sizeof(buf));
> memset(snap_tag, 0, sizeof(snap_tag));
> pstrcpy(buf, SD_MAX_VDI_LEN, s->name);
> - if (qemu_strtoul(snapshot_id, NULL, 10, (unsigned long *)&snap_id)) {
> + if (qemu_strtoul(snapshot_id, NULL, 10, &snap_id)) {
> return -1;
> }
>
> if (snap_id) {
> - hdr.snapid = snap_id;
> + hdr.snapid = (uint32_t) snap_id;
Maybe we should do an overflow check before?
Max
> } else {
> pstrcpy(snap_tag, sizeof(snap_tag), snapshot_id);
> pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, snap_tag);
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-03-02 15:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 15:16 [Qemu-devel] [PATCH 1/1] block/sheepdog: fix argument passed to qemu_strtoul() Jeff Cody
2016-03-02 15:27 ` Max Reitz [this message]
2016-03-02 15:38 ` [Qemu-devel] [Qemu-block] " Jeff Cody
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=56D70663.7030202@redhat.com \
--to=mreitz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mitake.hitoshi@lab.ntt.co.jp \
--cc=namei.unix@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=v.tolstov@selfip.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.