mirror of
https://github.com/nmap/nmap.git
synced 2026-01-20 13:19:01 +00:00
Avoid boolean tautologies of the form 'not x == y'
Lua operator 'not' has higher precedence than '==', so the statement
not x == "something"
is equivalent to:
(not x) == "something"
which will always be false, since the value of 'not x' will be either
'true' or 'false' and the string "something" is not the boolean 'true'
or 'false'. This is usually resolved by using the '~=' operator.
This commit is contained in:
@@ -86,7 +86,7 @@ Cisco = {
|
||||
local path = '/'
|
||||
local response = http.head(self.host, self.port, path, options)
|
||||
-- account for redirects
|
||||
if not response.status == 200 then
|
||||
if response.status ~= 200 then
|
||||
return false, "Failed to connect to SSL VPN server"
|
||||
elseif response.location then
|
||||
local u = url.parse(response.location[#response.location])
|
||||
|
||||
@@ -1156,7 +1156,7 @@ Torrent =
|
||||
end
|
||||
|
||||
-- the action in the response has to be 0 too
|
||||
if not r_action == "00000000" then
|
||||
if r_action ~= "00000000" then
|
||||
return false, "Wrong action field, usually caused by an erroneous request"
|
||||
end
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ action = function()
|
||||
-- single interface defined
|
||||
local interface = interface_opt or interface_arg
|
||||
local if_table = nmap.get_interface_info(interface)
|
||||
if not if_table or not if_table.address or not if_table.link=="ethernet" then
|
||||
if not (if_table and if_table.address and if_table.link=="ethernet") then
|
||||
stdnse.debug1("Interface not supported or not properly configured.")
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -193,7 +193,7 @@ function dropByte (dnsPacket)
|
||||
-- Iterate over every byte in the packet
|
||||
dnsPacket:gsub(".", function(c)
|
||||
i=i+1
|
||||
if not i==byteToDrop then
|
||||
if i ~= byteToDrop then
|
||||
newPacket[#newPacket+1] = c
|
||||
end
|
||||
end)
|
||||
@@ -328,7 +328,7 @@ action = function(host, port)
|
||||
query = makePacket ()
|
||||
-- induce random jitter
|
||||
retStr = corruptAndSend (host, port, query)
|
||||
if not retStr==nil then
|
||||
if retStr then
|
||||
return retStr
|
||||
end
|
||||
end
|
||||
|
||||
@@ -268,7 +268,7 @@ action = function()
|
||||
-- single interface defined
|
||||
local interface = interface_opt or interface_arg
|
||||
local if_table = nmap.get_interface_info(interface)
|
||||
if not if_table or not if_table.address or not if_table.link=="ethernet" then
|
||||
if not (if_table and if_table.address and if_table.link=="ethernet") then
|
||||
stdnse.debug1("Interface not supported or not properly configured.")
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user