Received: from eggs.gnu.org ([2001:4830:134:3::10]:59375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anpAR-0005GJ-6T for qemu-devel@nongnu.org; Wed, 06 Apr 2016 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anpAL-0002E5-Lg for qemu-devel@nongnu.org; Wed, 06 Apr 2016 11:14:51 -0400 From: Max Reitz Date: Wed, 6 Apr 2016 17:14:35 +0200 Message-Id: <1459955675-24011-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] 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 --- block/qcow2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 056525c..011a0ae 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1957,6 +1957,11 @@ int qcow2_update_header(BlockDriverState *bs) if (s->image_backing_file) { size_t backing_file_len = strlen(s->image_backing_file); + if (backing_file_len > 1023) { + ret = -EINVAL; + goto fail; + } + if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; -- 2.8.0