Nmap Development mailing list archives

Re: Some patches


From: arrowdodger <6yearold () gmail com>
Date: Mon, 8 Oct 2012 10:56:25 +0400

On Sun, Oct 7, 2012 at 12:22 AM, David Fifield <david () bamsoftware com>wrote:

On Fri, Oct 05, 2012 at 06:15:43PM +0400, arrowdodger wrote:
Hi, i have some patches fixing buildsystem stuff and adding clang
compatability:

http://intara.arrowdodger.ru/patch-clang-fixes

--- scan_engine.cc_     2012-10-05 11:13:12.003554110 +0400
+++ scan_engine.cc      2012-10-05 11:14:37.463551910 +0400
@@ -2904,7 +2904,7 @@
   }
   if (o.spoofsource && !bind_failed) {
     o.SourceSockAddr(&ss, &sslen);
-    if (bind(sd, (struct sockaddr*)&ss, sslen) != 0) {
+    if (::bind(sd, (struct sockaddr*)&ss, sslen) != 0) {
       error("%s: Problem binding source address (%s), errno: %d",
__func__, inet_socktop(&ss), socket_errno());
       perror("bind");
       bind_failed = 1;
--- traceroute.cc_      2012-10-05 11:33:54.413552510 +0400
+++ traceroute.cc       2012-10-05 11:34:15.976550750 +0400
@@ -169,8 +169,6 @@
 /* A global random token used to distinguish this traceroute's probes
from
    those of other traceroutes possibly running on the same machine. */
 static u16 global_id;
-/* A global cache of known hops, indexed by TTL and address. */
-static std::map<struct HopIdent, Hop *> hop_cache;
 /* A list of timedout hops, which are not kept in hop_cache, so we can
delete
    all hops on occasion. */
 static std::list<Hop *> timedout_hops;
@@ -204,6 +202,9 @@
   }
 };

+/* A global cache of known hops, indexed by TTL and address. */
+static std::map<struct HopIdent, Hop *> hop_cache;
+
 struct Hop {
   Hop *parent;
   struct sockaddr_storage tag;

Can you give us some more information on this patch? What version of
Clang do you use? People have successfully built using Clang in the
past. What are the specific warnings or errors that you see?


For the bind() call:

 scan_engine.cc:2907:48: error: invalid operands to binary expression
('__bind<int &, sockaddr *, unsigned long &>' and 'int')
    if (bind(sd, (struct sockaddr*)&ss, sslen) != 0) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~

Without :: clang confuses C bind function and std::bind().

For that hop_cache thing:

In file included from traceroute.cc:134:
In file included from ./nmap_dns.h:96:
In file included from /usr/include/c++/v1/string:434:
In file included from /usr/include/c++/v1/algorithm:593:
/usr/include/c++/v1/utility:220:9: error: field has incomplete type 'const
HopIdent'
    _T1 first;
        ^
...
traceroute.cc:173:41: note: in instantiation of exception specification for
'map' requested here
static std::map<struct HopIdent, Hop *> hop_cache;
                                        ^
traceroute.cc:173:24: note: forward declaration of 'HopIdent'
static std::map<struct HopIdent, Hop *> hop_cache;
                       ^
It basically says, that it can't instantiate std::map without knowning what
HopIdent is.

My clang version is "FreeBSD clang version 3.1 (branches/release_31 156863)
20120523"
Note that i'm building with "-std=c++11 -stdlib=libc++" flags.
I think, you haven't catched these error because you were building with
default std (c++03, AFAIK).


http://intara.arrowdodger.ru/patch-configure-cxxflags-fix

--- _configure  2012-10-05 10:15:36.678551512 +0400
+++ configure   2012-10-05 10:15:45.366548872 +0400
@@ -2398,7 +2398,7 @@
      fi
    if test -d /usr/local/include; then
      CFLAGS="$CFLAGS -I/usr/local/include"
-     CXXFLAGS="$CFLAGS -I/usr/local/include"
+     CXXFLAGS="$CXXFLAGS -I/usr/local/include"
    fi
 fi

Thanks, this was a real bug and I have committed it.

http://intara.arrowdodger.ru/patch-Makefile-cxxflags-fix

--- Makefile.in_        2012-10-05 10:17:36.037550752 +0400
+++ Makefile.in 2012-10-05 10:17:08.205548992 +0400
@@ -46,7 +46,7 @@
 # DEFS += -DMTRACE=1
 CXXFLAGS = @CXXFLAGS@ $(DBGFLAGS) $(CCOPT)
 CPPFLAGS = @CPPFLAGS@ $(DEFS)
-export CFLAGS = $(CXXFLAGS)
+export CFLAGS = @CFLAGS@
 # CFLAGS = $(DEFS) $(INCLS)
 STATIC =
 LDFLAGS = @LDFLAGS@ $(DBGFLAGS) $(STATIC)

I think it is intentional that CFLAGS is getting a copy of CXXFLAGS, so
I didn't commit this.


Well, the flags i use are specific for C++, so clang gives me error:
error: invalid argument '-std=c++11' not allowed with 'C/ObjC'
I think it's wrong to mix C and CXX flags, but i'm fine if you leave it as
it is, since my setup is quite uncommon.


David Fifield

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


Current thread: