Nmap Development mailing list archives
Re: Completed Lua 5.3 upgrade!
From: jah <jah () zadkiel plus com>
Date: Thu, 11 Aug 2016 22:02:38 +0100
An issue related to Lua5.3 upgrade. This one starts with a float (from nmap.clock) being passed to bin.pack(">i",
int32) from rpc.lua.
Translation of the bin.pack args to string.pack ones fail because float cannot be converted to an int (tointeger
returns nil):-
|/usr/local/bin/../share/nmap/nselib/bin.lua:71: assertion failed! stack traceback: [C]: in function 'assert'
/usr/local/bin/../share/nmap/nselib/bin.lua:71: in upvalue 'clamp' /usr/local/bin/../share/nmap/nselib/bin.lua:155: in
function </usr/local/bin/../share/nmap/nselib/bin.lua:97> [C]: in function 'string.gsub'
/usr/local/bin/../share/nmap/nselib/bin.lua:178: in function 'bin.pack' (...tail calls...)
/usr/local/bin/../share/nmap/nselib/rpc.lua:342: in method 'CreateHeader'
/usr/local/bin/../share/nmap/nselib/rpc.lua:495: in method 'EncodePacket'
/usr/local/bin/../share/nmap/nselib/rpc.lua:914: in method 'Export' /usr/local/bin/../share/nmap/nselib/rpc.lua:2406:
in function </usr/local/bin/../share/nmap/nselib/rpc.lua:2387> (...tail calls...)
/usr/local/bin/../share/nmap/scripts/nfs-ls.nse:366: in function </usr/local/bin/../share/nmap/scripts/nfs-ls.nse:344>
(...tail calls...)|
patch for rpc.lua:-
diff --git a/nselib/rpc.lua b/nselib/rpc.lua
index 9f7c03e..167e9c6 100644
--- a/nselib/rpc.lua
+++ b/nselib/rpc.lua
@@ -339,7 +339,7 @@ Comm = {
elseif auth.type == Portmap.AuthType.UNIX then
packet = packet .. Util.marshall_int32(auth.type)
local blob = (
- Util.marshall_int32(nmap.clock()) --time
+ Util.marshall_int32(math.floor(nmap.clock())) --time
.. Util.marshall_vopaque(auth.hostname or 'localhost')
.. Util.marshall_int32(auth.uid or 0)
.. Util.marshall_int32(auth.gid or 0)|
|PR on github: https://github.com/nmap/nmap/pull/499
Fixes: https://github.com/nmap/nmap/issues/494
jah
On 18/06/16 17:00, Daniel Miller wrote:
Patrick,
I found another one. I'm bringing these all up on the list so we have a record of the kinds of bugs that can happen
in a Lua version upgrade. In ntp-date.nse, we calculate a timestamp as a floating-point number, then pass it via
stdnse.format_timestamp to os.date, which expects an integer. One way to fix this would be to ensure it's an integer
before we pass it in, but maybe we should use math.floor to clamp it down to an integer within
stdnse.format_timestamp? What do you think?
Dan
patch to do it in stdnse.lua:
diff --git a/nselib/stdnse.lua b/nselib/stdnse.lua
index 9662197..0d9d48c 100644
--- a/nselib/stdnse.lua
+++ b/nselib/stdnse.lua
@@ -554,7 +554,7 @@ function format_timestamp(t, offset)
else
local tz_string = format_tz(offset)
offset = offset or 0
- return date("!%Y-%m-%dT%H:%M:%S", t + offset) .. tz_string
+ return date("!%Y-%m-%dT%H:%M:%S", floor(t + offset)) .. tz_string
end
end
On Fri, Jun 17, 2016 at 7:43 PM, Patrick Donnelly <batrick () batbytes com <mailto:batrick () batbytes com>> wrote:
On Wed, Jun 8, 2016 at 9:31 PM, Patrick Donnelly <batrick () batbytes com <mailto:batrick () batbytes com>> wrote:
> Without further ado, here's the branch:
>
> https://github.com/batrick/nmap/tree/nse-lua53
If there are no questions/comments/complaints/objections, I'd like to
merge the branch sometime around next Friday. All feedback is still
welcome!
--
Patrick Donnelly
_______________________________________________ Sent through the dev mailing list https://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 02)
- Re: Completed Lua 5.3 upgrade! Tom Sellers (Jul 07)
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 07)
- Re: Completed Lua 5.3 upgrade! Paulino Calderon (Jul 15)
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 16)
- Re: Completed Lua 5.3 upgrade! Daniel Miller (Jul 16)
- Re: Completed Lua 5.3 upgrade! Paulino Calderon (Jul 17)
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 17)
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 07)
- Re: Completed Lua 5.3 upgrade! Tom Sellers (Jul 07)
- Re: Completed Lua 5.3 upgrade! Patrick Donnelly (Jul 07)
- <Possible follow-ups>
- Re: Completed Lua 5.3 upgrade! jah (Aug 11)
