Blame SOURCES/kvm-block-Don-t-copy-backing-file-name-on-error.patch

218e99
From b0f9197ca9efa3768253bfab3b938d06e1d2abc1 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Thu, 7 Nov 2013 11:19:18 +0100
218e99
Subject: [PATCH 66/87] block: Don't copy backing file name on error
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383823158-8741-1-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55596
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 25/24] block: Don't copy backing file name on error
218e99
Bugzilla: 978402
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
218e99
bdrv_open_backing_file() tries to copy the backing file name using
218e99
pstrcpy directly after calling bdrv_open() to open the backing file
218e99
without checking whether that was actually successful. If it was not,
218e99
ps->backing_hd->file will probably be NULL and qemu will crash.
218e99
218e99
Fix this by moving pstrcpy after checking whether bdrv_open() succeeded.
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Reviewed-by: Benoit Canet <benoit@irqsave.net>
218e99
Reviewed-by: Amos Kong <kongjianjun@gmail.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 61ed2684539f7f31304e193d7c0e68d57ce6be88)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
218e99
Brewing as: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6541865
218e99
218e99
---
218e99
 block.c | 4 ++--
218e99
 1 file changed, 2 insertions(+), 2 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block.c |    4 ++--
218e99
 1 files changed, 2 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/block.c b/block.c
218e99
index beeb600..dccdb2c 100644
218e99
--- a/block.c
218e99
+++ b/block.c
218e99
@@ -974,8 +974,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
218e99
     ret = bdrv_open(bs->backing_hd,
218e99
                     *backing_filename ? backing_filename : NULL, options,
218e99
                     back_flags, back_drv, &local_err);
218e99
-    pstrcpy(bs->backing_file, sizeof(bs->backing_file),
218e99
-            bs->backing_hd->file->filename);
218e99
     if (ret < 0) {
218e99
         bdrv_delete(bs->backing_hd);
218e99
         bs->backing_hd = NULL;
218e99
@@ -983,6 +981,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
218e99
         error_propagate(errp, local_err);
218e99
         return ret;
218e99
     }
218e99
+    pstrcpy(bs->backing_file, sizeof(bs->backing_file),
218e99
+            bs->backing_hd->file->filename);
218e99
     return 0;
218e99
 }
218e99
 
218e99
-- 
218e99
1.7.1
218e99