1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-06 14:39:03 +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:
dmiller
2016-05-23 04:30:06 +00:00
parent 5be0ac591b
commit 9450cb725a
5 changed files with 6 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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