Skip to content

Commit 9ab68ac

Browse files
committed
Fix unintelligible error when importing empty file
IO#read returns nil for an empty file if given a length argument, which caused a stack trace when attempting to import a file instead of a useful error message.
1 parent 9e78858 commit 9ab68ac

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/msf/core/db.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,9 @@ def import_file(args={}, &block)
27972797
::File.open(filename, 'rb') do |f|
27982798
data = f.read(4)
27992799
end
2800+
if data.nil?
2801+
raise DBImportError.new("Zero-length file")
2802+
end
28002803

28012804
case data[0,4]
28022805
when "PK\x03\x04"

0 commit comments

Comments
 (0)