From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8gh-00074R-Mq for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:27:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ab8gg-0003zK-NV for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:27:43 -0500 References: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com> From: Max Reitz Message-ID: <56D70663.7030202@redhat.com> Date: Wed, 2 Mar 2016 16:27:31 +0100 MIME-Version: 1.0 In-Reply-To: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="A24bXfMtWkS69qmCai34hGJ3SWiPg0vkl" Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/1] block/sheepdog: fix argument passed to qemu_strtoul() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , 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 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --A24bXfMtWkS69qmCai34hGJ3SWiPg0vkl Content-Type: multipart/mixed; boundary="lM8Xkiln1poB0r8Xot7Qu2bRdVIpCpDHT" From: Max Reitz To: Jeff Cody , 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 Message-ID: <56D70663.7030202@redhat.com> Subject: Re: [Qemu-block] [PATCH 1/1] block/sheepdog: fix argument passed to qemu_strtoul() References: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com> In-Reply-To: <780d0c59f2993cec4a0931df93b9fe12cb5d0f46.1456931418.git.jcody@redhat.com> --lM8Xkiln1poB0r8Xot7Qu2bRdVIpCpDHT Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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. >=20 > Even though the snap_id field in the header is 32-bits, we must > accomodate the full size in qemu_strtoul(). >=20 > Reported-by: Paolo Bonzini > Signed-off-by: Jeff Cody > --- > block/sheepdog.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > 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 *b= s, > const char *name, > Error **errp) > { > - uint32_t snap_id =3D 0; > + unsigned long snap_id =3D 0; > char snap_tag[SD_MAX_VDI_TAG_LEN]; > Error *local_err =3D 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; > } > =20 > if (snap_id) { > - hdr.snapid =3D snap_id; > + hdr.snapid =3D (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); >=20 --lM8Xkiln1poB0r8Xot7Qu2bRdVIpCpDHT-- --A24bXfMtWkS69qmCai34hGJ3SWiPg0vkl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJW1wZjAAoJEDuxQgLoOKytmpMIAIqyFYEK9Xm9QtT3nsH9Jw7l OXRtbJfD5CAhXfv9UNHXEdoCkRLO6Z3thYA5B513lPQC1d/KYJ6UCrEmd25k3v5D sXZ65NDSGrf707AlA/jZ5NrQocJDCX735tapyxXdEeTVMZKvPYI4sl3WSgjas3Ju yRy7Dwg+yfOA//SliRqRRZ/Z0Ak8vl9EUuWTGul6QyKWiQX/07TCUgkimRwD/rbc IKJrmNLvRwGu5V5HapwXYea/vYQc+HguufwlSjFGlFdD94T6DIr8btowhZobsO50 Gg6CfZtIsJV9hUUXP2IOxI9IsXQ6wt+NfrJT0en3mKQgQmpe9Rex/zvHWOrMywc= =ZNCg -----END PGP SIGNATURE----- --A24bXfMtWkS69qmCai34hGJ3SWiPg0vkl--