Skip to content

Commit 4906327

Browse files
author
Brent Cook
committed
Land rapid7#6702, fix datastore option 'stickiness', fix OptPort validation
2 parents 0c7cf29 + 866c471 commit 4906327

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

lib/msf/core/data_store.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def update_value(k, v)
7575
#
7676
def import_options(options, imported_by = nil, overwrite = false)
7777
options.each_option do |name, opt|
78-
# Skip options without a default or if is already a value defined
79-
if !opt.default.nil? && (!self.has_key?(name) || overwrite)
78+
if self[name].nil? || overwrite
8079
import_option(name, opt.default, true, imported_by, opt)
8180
end
8281
end

lib/msf/core/opt_port.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,17 @@ module Msf
77
# Network port option.
88
#
99
###
10-
class OptPort < OptBase
10+
class OptPort < OptInt
1111
def type
1212
return 'port'
1313
end
1414

15-
def normalize(value)
16-
value.to_i
17-
end
18-
1915
def valid?(value)
20-
return false if empty_required_value?(value)
21-
22-
if ((value != nil and value.to_s.empty? == false) and
23-
((value.to_s.match(/^\d+$/) == nil or value.to_i < 0 or value.to_i > 65535)))
24-
return false
16+
if !required? and value.to_s.empty?
17+
super
18+
else
19+
super && normalize(value) <= 65535 && normalize(value) >= 0
2520
end
26-
27-
return super
2821
end
2922
end
3023

0 commit comments

Comments
 (0)