<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 84d60ba73af642642c50e35a2559af25051e6d1e Mon Sep 17 00:00:00 2001
From: Max Reitz &lt;mreitz@redhat.com&gt;
Date: Fri, 27 May 2016 10:59:07 +0200
Subject: [PATCH] qcow2: Prevent backing file names longer than 1023

RH-Author: Max Reitz &lt;mreitz@redhat.com&gt;
Message-id: &lt;1464346747-27992-2-git-send-email-mreitz@redhat.com&gt;
Patchwork-id: 70494
O-Subject: [RHEV-7.2.z qemu-kvm-rhev PATCH 1/1] qcow2: Prevent backing file names longer than 1023
Bugzilla: 1340045
RH-Acked-by: Fam Zheng &lt;famz@redhat.com&gt;
RH-Acked-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
RH-Acked-by: John Snow &lt;jsnow@redhat.com&gt;

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 &lt;mreitz@redhat.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
(cherry picked from commit 4e876bcf2bdb3a7353df92d19bfec0afd1650bc4)
Signed-off-by: Max Reitz &lt;mreitz@redhat.com&gt;
Signed-off-by: Miroslav Rezanina &lt;mrezanin@redhat.com&gt;
---
 block/qcow2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index cab8450..c3646a6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1725,6 +1725,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs,
 {
     BDRVQcowState *s = bs-&gt;opaque;
 
+    if (backing_file &amp;&amp; strlen(backing_file) &gt; 1023) {
+        return -EINVAL;
+    }
+
     pstrcpy(bs-&gt;backing_file, sizeof(bs-&gt;backing_file), backing_file ?: "");
     pstrcpy(bs-&gt;backing_format, sizeof(bs-&gt;backing_format), backing_fmt ?: "");
 
-- 
1.8.3.1

</pre></body></html>