9ae3a8
From 0a5d705e471c975ca6ca4547cd3a0eb5fa5d3291 Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Mon, 27 Nov 2017 17:28:39 +0100
9ae3a8
Subject: [PATCH 7/9] qcow2: Prevent backing file names longer than 1023
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <20171127172839.22264-2-mreitz@redhat.com>
9ae3a8
Patchwork-id: 77916
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH 1/1] qcow2: Prevent backing file names longer than 1023
9ae3a8
Bugzilla: 1459714
9ae3a8
RH-Acked-by: John Snow <jsnow@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
We reject backing file names with a length of more than 1023 characters
9ae3a8
when opening a qcow2 file, so we should not produce such files
9ae3a8
ourselves.
9ae3a8
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 4e876bcf2bdb3a7353df92d19bfec0afd1650bc4)
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/qcow2.c | 4 ++++
9ae3a8
 1 file changed, 4 insertions(+)
9ae3a8
9ae3a8
diff --git a/block/qcow2.c b/block/qcow2.c
9ae3a8
index 61f7e57..dc831ba 100644
9ae3a8
--- a/block/qcow2.c
9ae3a8
+++ b/block/qcow2.c
9ae3a8
@@ -1497,6 +1497,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs,
9ae3a8
 {
9ae3a8
     BDRVQcowState *s = bs->opaque;
9ae3a8
 
9ae3a8
+    if (backing_file && strlen(backing_file) > 1023) {
9ae3a8
+        return -EINVAL;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");
9ae3a8
     pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: "");
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8