diff --git a/lib/vagrant/box_collection2.rb b/lib/vagrant/box_collection2.rb index 830aa7e90..04c837cdd 100644 --- a/lib/vagrant/box_collection2.rb +++ b/lib/vagrant/box_collection2.rb @@ -26,6 +26,7 @@ module Vagrant # * BoxAlreadyExists - The box you're attempting to add already exists. # * BoxProviderDoesntMatch - If the given box provider doesn't match the # actual box provider in the untarred box. + # * BoxUnpackageFailure - An invalid tar file. # * BoxUpgradeRequired - You're attempting to add a box when there is a # V1 box with the same name that must first be upgraded. # @@ -53,7 +54,11 @@ module Vagrant # Change directory to the box directory and unpackage the tar Dir.chdir(box_dir) do @logger.debug("Unpacking box file into box directory...") - Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s) + begin + Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s) + rescue SystemCallError + raise Errors::BoxUnpackageFailure + end end # Find the box we just added diff --git a/test/unit/vagrant/box_collection2_test.rb b/test/unit/vagrant/box_collection2_test.rb index b99bd765c..ee95e3694 100644 --- a/test/unit/vagrant/box_collection2_test.rb +++ b/test/unit/vagrant/box_collection2_test.rb @@ -65,6 +65,10 @@ describe Vagrant::BoxCollection2 do # Verify the box doesn't exist instance.find(box_name, bad_provider).should be_nil end + + it "should raise an exception if you add an invalid box file" do + pending "I don't know how to generate an invalid tar." + end end describe "listing all" do