Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [patch] Fixes for new Lua 5.2-isms
From: Patrick Donnelly <batrick () batbytes com>
Date: Tue, 29 May 2012 12:16:34 -0400

On Tue, May 29, 2012 at 11:51 AM, Daniel Miller <bonsaiviking () gmail com> wrote:
List,

While debugging, I found a few errors due to using old names of library
functions, like this one:

./nselib/rpc.lua:3365: attempt to call field 'mod' (a nil value)
stack traceback:
       ./nselib/rpc.lua:3365: in function 'CalcFillBytes'
       ./nselib/rpc.lua:3052: in function 'unmarshall_vopaque'
       ./nselib/rpc.lua:920: in function 'Export'
       ./nselib/rpc.lua:2325: in function 'ShowMounts'
       ./scripts/nfs-showmount.nse:42: in function
<./scripts/nfs-showmount.nse:37>
       (...tail calls...)


So I went through the "Changes" sections of the Lua 5.2 and 5.1 manuals, and
checked for obvious fixes. Here's the mini-changelog I ended up with:


   Fix math.mod (renamed to math.fmod in 5.1)
   Fix foreach (now use for loop over pairs)
   Replace string.gfind with string.gmatch (changed in 5.1)
   Rename unpack to table.unpack (only when necessary, due to bin.unpack,
local unpack=table.unpack, etc. New in 5.2)
   %z in patterns deprecated for \0 (deprecated in 5.2)

I think some of these 5.1-isms were covered by LUA_COMPAT* defines in
luaconf.h before the 5.2 change. Hopefully this patch will result in better
results from here forward.

Patch looks good to me. Great job finding these.

-- 
- Patrick Donnelly
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault