From 5031df5ade0eefdb30a849fea43f2f025319b334 Mon Sep 17 00:00:00 2001 From: Simon Boulet Date: Mon, 11 Mar 2013 20:08:44 -0400 Subject: [PATCH] Bug #1810: Fix oned crash when calling attachdisk with an improperly formated DISK template Signed-off-by: Simon Boulet (cherry picked from commit 60b47c7183909acec28550834f0b32cb3b8a2382) --- include/Attribute.h | 2 +- src/vm/VirtualMachine.cc | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/Attribute.h b/include/Attribute.h index c0793b67f7..bc1e3b75f3 100644 --- a/include/Attribute.h +++ b/include/Attribute.h @@ -355,7 +355,7 @@ public: /** * Clones the current attribute */ - Attribute* clone() const + VectorAttribute* clone() const { return new VectorAttribute(*this); }; diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 126881d4e1..9d34ef2962 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1260,7 +1260,15 @@ VectorAttribute * VirtualMachine::set_up_attach_disk( return 0; } - new_disk = new VectorAttribute(*(dynamic_cast(disks[0]))); + new_disk = dynamic_cast(disks[0]); + + if ( new_disk == 0 ) + { + error_str = "Internal error parsing DISK attribute"; + return 0; + } + + new_disk = new_disk->clone(); // ------------------------------------------------------------------------- // Acquire the new disk image