mirror of
https://github.com/nmap/nmap.git
synced 2025-12-31 03:49:01 +00:00
Don't strip leading 0s in stdnse.tobinary
Every place this function is used, the result is padded with 0s anyway, so may as well not strip them here. Didn't remove the padding code since this could return only 4 chars, and most padding is to 8-char width.
This commit is contained in:
@@ -260,12 +260,12 @@ do
|
||||
};
|
||||
|
||||
--- Converts the given number, n, to a string in a binary number format (12
|
||||
-- becomes "1100").
|
||||
-- becomes "1100"). Leading 0s not stripped.
|
||||
-- @param n Number to convert.
|
||||
-- @return String in binary format.
|
||||
function tobinary(n)
|
||||
assert(tonumber(n), "number expected");
|
||||
return (("%x"):format(n):gsub("%w", t):gsub("^0*", ""));
|
||||
return (("%x"):format(n):gsub("%w", t))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user