Skip to content

Commit ad374c2

Browse files
committed
Use ASCII-8BIT for comparing pcap magic number
In Ruby 2, source files are read as UTF-8 by default. When comparing PCAP headers, we should use ASCII-8BIT or else the comparison will not work. This should be backwards compatible with Ruby 1.9. MSP-12092
1 parent 2c7777f commit ad374c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/msf/core/db_manager/import.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def import_file(args={}, &block)
119119
# Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as Zip here, so need to use ::Zip so Zip
120120
# is resolved as one from rubyzip gem.
121121
data = ::Zip::File.open(filename)
122-
when "\xd4\xc3\xb2\xa1", "\xa1\xb2\xc3\xd4"
122+
when "\xd4\xc3\xb2\xa1".force_encoding('ASCII-8BIT'), "\xa1\xb2\xc3\xd4".force_encoding('ASCII-8BIT')
123123
data = PacketFu::PcapFile.new(:filename => filename)
124124
else
125125
::File.open(filename, 'rb') do |f|

0 commit comments

Comments
 (0)