Nmap Development mailing list archives

Re: [nmap-svn] r36162 - nmap/nselib/data


From: Patrick Donnelly <batrick () batbytes com>
Date: Mon, 22 Aug 2016 15:23:19 -0400

On Mon, Aug 22, 2016 at 1:33 PM, nnposter
<nnposter () users sourceforge net> wrote:
The other option you mentioned directly to me was: local _, openssl =
pcall(require, "openssl"); This option should not be used, since "_" is
considered a throwaway variable name; It could easily be overwritten,
and code that tests it doesn't make sense. So it would open us up to
crashes when someone writes unconditional code that tries to index the
nonexistent openssl library.

I do not believe that my example...

    local _, openssl = pcall(require, 'openssl')
    ...
    if openssl and openssl.md5 then

...had any dependency on "_", namely there was no explicit or implicit
"code that tests it", so I am not quite sure that I understand your point.

To satisfy my curiosity, could you please point out what specifically
would be wrong with the example? (To make it clear, I am not opposed to
option #3; I have used it in the original commit after all. I am just
trying to understand the pitfalls with option #4.)

You could also do this to avoid creating the _ variable:

local openssl = select(2, pcall(require, "openssl"))

(I have no strong opinions on any of the options...)

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


Current thread: