Browse Source

fix normalisation so we don't coerce to 0

don't coerce nil to 0
David Maloney 3 years ago
parent
commit
53b989f283
No account linked to committer's email address
2 changed files with 4 additions and 2 deletions
  1. 3
    1
      lib/msf/core/opt_int.rb
  2. 1
    1
      lib/msf/core/opt_port.rb

+ 3
- 1
lib/msf/core/opt_int.rb View File

@@ -15,8 +15,10 @@ class OptInt < OptBase
15 15
   def normalize(value)
16 16
     if value.to_s.match(/^0x[a-fA-F\d]+$/)
17 17
       value.to_i(16)
18
-    else
18
+    elsif value.present?
19 19
       value.to_i
20
+    else
21
+      nil
20 22
     end
21 23
   end
22 24
 

+ 1
- 1
lib/msf/core/opt_port.rb View File

@@ -13,7 +13,7 @@ class OptPort < OptInt
13 13
   end
14 14
 
15 15
   def valid?(value, check_empty: true)
16
-    port = normalize(value)
16
+    port = normalize(value).to_i
17 17
     super && port <= 65535 && port >= 0
18 18
   end
19 19
 end

Loading…
Cancel
Save