Received: from eggs.gnu.org ([2001:4830:134:3::10]:59412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5F6u-0006Ns-18 for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5F6r-0002cl-DB for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:28 -0500 From: Kevin Wolf Date: Fri, 11 Nov 2016 17:55:04 +0100 Message-Id: <1478883311-24052-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1478883311-24052-1-git-send-email-kwolf@redhat.com> References: <1478883311-24052-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 05/12] raw_bsd: don't check size alignment when only offset is set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD We make sure that the size is aligned to sector length to prevent any round ups. Otherwise we could end up reading/writing data outside the area specified by user. This is only needed when user supplies the size option to avoid any surprises. It is not necessary when only offset is set. More over, the check made it difficult to use the offset option without size option. The check puts unneeded restriction on the offset which had to be aligned too. Because bdrv_getlength() returns aligned value having unaligned offset would make the check fail. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Signed-off-by: Kevin Wolf --- block/raw_bsd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/raw_bsd.c b/block/raw_bsd.c index cf7a560..8a5b9b0 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -119,7 +119,7 @@ static int raw_read_options(QDict *options, BlockDriv= erState *bs, =20 /* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent roundin= g * up and leaking out of the specified area. */ - if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) { + if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) { error_setg(errp, "Specified size is not multiple of %llu", BDRV_SECTOR_SIZE); ret =3D -EINVAL; --=20 1.8.3.1