From 0468dbeabe3bf38e20dd2fc8d4b56cd530976629 Mon Sep 17 00:00:00 2001 From: Tod Beardsley Date: Mon, 27 Dec 2010 16:30:08 +0000 Subject: [PATCH] Fixes a db_import bug introduced in r11355 . git-svn-id: file:///home/svn/framework3/trunk@11416 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/db.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index 78f0ab8557..ba0707ba1f 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -1965,11 +1965,7 @@ class DBManager # If there is no match, an error is raised instead. def import_filetype_detect(data) - if not (data and data.length > 0) - raise DBImportError.new("The data provided to the import function was empty") - end - - if data.kind_of? Zip::ZipFile + if data and data.kind_of? Zip::ZipFile raise DBImportError.new("The zip file provided is empty.") if data.entries.empty? @import_filedata ||= {} @import_filedata[:zip_filename] = File.split(data.to_s).last @@ -1985,7 +1981,7 @@ class DBManager end end - if data.kind_of? PacketFu::PcapFile + if data and data.kind_of? PacketFu::PcapFile raise DBImportError.new("The pcap file provided is empty.") if data.body.empty? @import_filedata ||= {} @import_filedata[:type] = "Libpcap Packet Capture" @@ -1993,6 +1989,10 @@ class DBManager end # Text string kinds of data. + if data and data.to_s.strip.size.zero? + raise DBImportError.new("The data provided to the import function was empty") + end + di = data.index("\n") firstline = data[0, di] @import_filedata ||= {}