From 9ab68ac9355fc1fac0835a35e5bc8442caddda57 Mon Sep 17 00:00:00 2001 From: James Lee Date: Tue, 7 May 2013 18:05:45 -0500 Subject: [PATCH] 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. --- lib/msf/core/db.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index 99f392e2d9..0ffce1493d 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -2797,6 +2797,9 @@ class DBManager ::File.open(filename, 'rb') do |f| data = f.read(4) end + if data.nil? + raise DBImportError.new("Zero-length file") + end case data[0,4] when "PK\x03\x04"