From patchwork Wed Mar 2 15:16:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 8481761 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0FA8CC0553 for ; Wed, 2 Mar 2016 15:16:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EBF420386 for ; Wed, 2 Mar 2016 15:16:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D257820383 for ; Wed, 2 Mar 2016 15:16:37 +0000 (UTC) Received: from localhost ([::1]:57049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8Vx-00027O-2e for patchwork-qemu-devel@patchwork.kernel.org; Wed, 02 Mar 2016 10:16:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8Vm-00026i-Ch for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:16:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ab8Vi-0000zi-Dr for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:16:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8Vd-0000yR-7u; Wed, 02 Mar 2016 10:16:17 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id CE4E68F316; Wed, 2 Mar 2016 15:16:16 +0000 (UTC) Received: from localhost (ovpn-112-65.phx2.redhat.com [10.3.112.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u22FGEaa029961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 2 Mar 2016 10:16:16 -0500 From: Jeff Cody To: qemu-block@nongnu.org Date: Wed, 2 Mar 2016 10:16:14 -0500 Message-Id: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 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: [Qemu-devel] [PATCH 1/1] block/sheepdog: fix argument passed to qemu_strtoul() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Jeff Cody --- 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; } else { pstrcpy(snap_tag, sizeof(snap_tag), snapshot_id); pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, snap_tag);