summaryrefslogtreecommitdiff
path: root/lib/chef/formatters/base.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-07-30 11:21:11 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-07-31 17:44:05 -0700
commit0875b1cd90ca9d8b173c57b12b510359b5c01428 (patch)
tree0d919809cc6b5856ce8f15af470e3e03d411e91f /lib/chef/formatters/base.rb
parent3583c9fc48b3bc5a5c2afca3e48620589afe1c5e (diff)
downloadchef-0875b1cd90ca9d8b173c57b12b510359b5c01428.tar.gz
Prevent indentation from being set to negative numbers
If we don't defensively program here, the result is terrible. All that gets raised is "negative argument" from deep within the formatter and from then on the formatter is broken. It will continue to raise errors from events called from inside the Chef::Client exception handler and you're gonna have a bad time.
Diffstat (limited to 'lib/chef/formatters/base.rb')
-rw-r--r--lib/chef/formatters/base.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 636ba9c83f..af041a5081 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -93,6 +93,11 @@ class Chef
def indent_by(amount)
@output.indent += amount
+ if @output.indent < 0
+ #Chef::Log.warn "Internal Formatter Error -- Attempt to indent by negative number of spaces"
+ @output.indent = 0
+ end
+ @output.indent
end
# Input: a Formatters::ErrorDescription object.