Nmap Development mailing list archives

Re: Version display patch


From: David Fifield <david () bamsoftware com>
Date: Fri, 4 Feb 2011 15:09:14 -0800

On Fri, Feb 04, 2011 at 09:49:02PM +0530, ambarisha b wrote:
I have attached the patch for -V option.This is the output on my machine.
$ nmap -V

Nmap version 5.51SVN ( http://nmap.org )
Platform : i686-pc-linux-gnu
Compiled with: liblua-5.1.3 libpcre-7.6 libpcap-1.1.1 libdnet-1.12 ipv6
Compiled without: OpenSSL

What do you think ?

Thanks for this! It's looking good. I attached a revised patch that I
hope makes the flow clearer. Here's my output:

Nmap version 5.51SVN ( http://nmap.org )
Platform: i686-pc-linux-gnu
Compiled with: liblua-5.1.4 openssl-1.0.0c libpcre-7.7 libpcap-1.1.1 libdnet-1.12 ipv6
Compiled without:

I'm a little concerned about the methods used to get library version
numbers. Here's a summary of what's happening:

liblua has LUA_RELEASE, a string like "Lua 5.1.3". The code is doing a
substr(4) to strip off the "Lua ". Other potential options like
LUA_VERSION_NUM are present in lua.h.

openssl provides OPENSSL_VERSION_TEXT, a string like
"OpenSSL 1.0.0c 2 Dec 2010". The code is doing a substr(8, 6) to extract
the "1.0.0c".

libpcre has the function pcre_version, which returns a string like
"7.7 2008-05-07". The code is deleting everything after and including
the first space to get "7.7".

libpcap has the function pcap_lib_version, returning a string like
"libpcap version 1.1.1". However there is a variable pcap_version that
contains the easier-to-use value "1.1.1". pcap_version doesn't appear to
be part of pcap's external interface, but we use it in acinclude.m4, so
it must be somewhat reliable.

libdnet exports a macro VERSION with value "1.1.2". The unqualified name
VERSION is annoying but otherwise this isn't problematic.

I think that libpcap and libdnet are fine as they are, but liblua,
openssl, and libpcre should be made more robust. Can you make a function
that returns the nth whitespace-separated word from a string, and make
display_nmap_version use that? Or example, it would extract the second
(index 1) word from "Lua 5.1.3", the second (index 1) word from "OpenSSL
1.0.0c 2 Dec 2010", and the first (index 0) word from "7.7 2008-05-07".
That's still not perfect but it's better than constant character
offsets.

David Fifield

Attachment: nmap-version.diff
Description:

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

Current thread: