Skip to content

Commit 1f48056

Browse files
committed
Protecting against 0 length file divide by 0 bug
1 parent 9952ec4 commit 1f48056

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

chef/lib/chef/rest.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ def run_request(method, url, data=false, limit=10, raw=false)
128128
response.read_body do |chunk|
129129
tf.write(chunk)
130130
size += chunk.size
131-
Chef::Log.debug("#{req.path} %d%% done (%d of %d)" % [(size * 100) / total, size, total])
131+
if size == 0
132+
Chef::Log.debug("#{req.path} done (0 length file)")
133+
else
134+
Chef::Log.debug("#{req.path} %d%% done (%d of %d)" % [(size * 100) / total, size, total])
135+
end
132136
end
133137
tf.close
134138
tf

0 commit comments

Comments
 (0)