Skip to content

Commit 53b989f

Browse files
David MaloneyDavid Maloney
authored andcommitted
fix normalisation so we don't coerce to 0
don't coerce nil to 0
1 parent 16030cd commit 53b989f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/msf/core/opt_int.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ def type
1515
def normalize(value)
1616
if value.to_s.match(/^0x[a-fA-F\d]+$/)
1717
value.to_i(16)
18-
else
18+
elsif value.present?
1919
value.to_i
20+
else
21+
nil
2022
end
2123
end
2224

lib/msf/core/opt_port.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def type
1313
end
1414

1515
def valid?(value, check_empty: true)
16-
port = normalize(value)
16+
port = normalize(value).to_i
1717
super && port <= 65535 && port >= 0
1818
end
1919
end

0 commit comments

Comments
 (0)