From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anqO1-0005dH-SR for qemu-devel@nongnu.org; Wed, 06 Apr 2016 12:32:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anqO1-0007Od-4f for qemu-devel@nongnu.org; Wed, 06 Apr 2016 12:32:57 -0400 From: Max Reitz Date: Wed, 6 Apr 2016 18:32:48 +0200 Message-Id: <1459960368-12250-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v2] qcow2: Prevent backing file names longer than 1023 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Max Reitz We reject backing file names with a length of more than 1023 characters when opening a qcow2 file, so we should not produce such files ourselves. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz --- v2: - Move the check to qcow2_change_backing_file() so the BDS state will not be modified if that condition is not met [Kevin] --- block/qcow2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 056525c..470734b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1986,6 +1986,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs, { BDRVQcow2State *s = bs->opaque; + if (backing_file && strlen(backing_file) > 1023) { + return -EINVAL; + } + pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); -- 2.8.0