diff --git a/CHANGELOG.md b/CHANGELOG.md index 5272bb5ab..ab4b80c1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ BUG FIXES: - core: Rare EINVAL errors on box adding are gone. [GH-3094] - core: Upgrading the home directory for Vagrant 1.5 uses the Vagrant temp dir. [GH-3095] + - core: Assume a box isn't metadata if it exceeds 20 MB. [GH-3107] ## 1.5.0 (March 10, 2014) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index 8573cae12..a801ca99a 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -14,6 +14,10 @@ module Vagrant # This middleware will download a remote box and add it to the # given box collection. class BoxAdd + # This is the size in bytes that if a file exceeds, is considered + # to NOT be metadata. + METADATA_SIZE_LIMIT = 20971520 + def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::action::builtin::box_add") @@ -445,6 +449,12 @@ module Vagrant begin File.open(url, "r") do |f| + if f.size > METADATA_SIZE_LIMIT + # Quit early, don't try to parse the JSON of gigabytes + # of box files... + return false + end + BoxMetadata.new(f) end return true