Nmap Development mailing list archives

Solaris nmap-3.28: patch for compile failures


From: Andrew Sun <asres4 () comcast net>
Date: Thu, 19 Jun 2003 20:49:14 -0400


Hello nmap developers,

A compile bug and patch for your consideration.

nmap-3.28
Solaris 8 sparc, Sun WS 6 U2 compilers (believed to produce
  better code than gcc compilers)


Fatal compilation errors:

CC -c -g -Ilibpcap-possiblymodified -Inbase -DHAVE_CONFIG_H -DNMAP_VERSION=\"3 .28\" -DNMAP_NAME=\"nmap\" -DNMAP_URL=\"www.insecure.org/nmap/\" -DNMAP_PLATFORM =\"sparc-sun-solaris2.8\" -DNMAPDATADIR=\"/usr/local/share/nmap\" -Ilibpcap-poss
iblymodified main.cc -o main.o
"/usr/include/netdb.h", line 412: Warning (Anachronism): Attempt to redefine MAX
HOSTNAMELEN without using #undef.
"libpcap-possiblymodified/pcap.h", line 201: Error: Only one of a set of overloa
ded functions can be extern "C".
"libpcap-possiblymodified/pcap.h", line 202: Error: Only one of a set of overloa
ded functions can be extern "C".
"main.cc", line 93: Warning: String literal converted to char* in initialization
.

...

2 Error(s) and 60 Warning(s) detected.
*** Error code 2
make: Fatal error: Command failed for target `main.o'



The fatal problem is Solaris C++ appears to define __STDC__ like this:
   #define __STDC__ 0
which results in unexpected behavior with:
   #if __STDC__
...
   #endif
code can be revised like this to fix: #ifdef __STDC__

Patch enclosed, solnmappatch.txt

*** nmap-3.28/libpcap-possiblymodified/bpf/net/bpf.h.orig       Wed Dec 18 01:10:07 2002
--- nmap-3.28/libpcap-possiblymodified/bpf/net/bpf.h    Thu Jun 19 13:51:29 2003
***************
*** 391,397 ****
   * Systems based on non-BSD kernels don't have ifnet's (or they don't mean
   * anything if it is in <net/if.h>) and won't work like this.
   */
! # if __STDC__
  extern void bpf_tap(struct ifnet *, u_char *, u_int);
  extern void bpf_mtap(struct ifnet *, struct mbuf *);
  extern void bpfattach(struct ifnet *, u_int, u_int);
--- 391,397 ----
   * Systems based on non-BSD kernels don't have ifnet's (or they don't mean
   * anything if it is in <net/if.h>) and won't work like this.
   */
! # ifdef __STDC__
  extern void bpf_tap(struct ifnet *, u_char *, u_int);
  extern void bpf_mtap(struct ifnet *, struct mbuf *);
  extern void bpfattach(struct ifnet *, u_int, u_int);
***************
*** 403,409 ****
  extern void bpfilterattach();
  # endif /* __STDC__ */
  #endif /* BSD && (_KERNEL || KERNEL) */
! #if __STDC__
  extern int bpf_validate(struct bpf_insn *, int);
  extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
  #else
--- 403,409 ----
  extern void bpfilterattach();
  # endif /* __STDC__ */
  #endif /* BSD && (_KERNEL || KERNEL) */
! #ifdef __STDC__
  extern int bpf_validate(struct bpf_insn *, int);
  extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
  #else
*** nmap-3.28/libpcap-possiblymodified/scanner.c.orig   Wed Dec 18 01:10:07 2002
--- nmap-3.28/libpcap-possiblymodified/scanner.c        Thu Jun 19 13:52:39 2003
***************
*** 32,38 ****
  
  #else /* ! __cplusplus */
  
! #if __STDC__
  
  #define YY_USE_PROTOS
  #define YY_USE_CONST
--- 32,38 ----
  
  #else /* ! __cplusplus */
  
! #ifdef __STDC__
  
  #define YY_USE_PROTOS
  #define YY_USE_CONST
***************
*** 1853,1859 ****
  #ifdef YY_MALLOC_DECL
  YY_MALLOC_DECL
  #else
! #if __STDC__
  #ifndef __cplusplus
  #include <stdlib.h>
  #endif
--- 1853,1859 ----
  #ifdef YY_MALLOC_DECL
  YY_MALLOC_DECL
  #else
! #ifdef __STDC__
  #ifndef __cplusplus
  #include <stdlib.h>
  #endif
*** nmap-3.28/libpcap-possiblymodified/grammar.c.orig   Wed Dec 18 01:10:07 2002
--- nmap-3.28/libpcap-possiblymodified/grammar.c        Thu Jun 19 13:53:56 2003
***************
*** 49,55 ****
  #include <sys/socket.h>
  #include <stdlib.h>
  
! #if __STDC__
  struct mbuf;
  struct rtentry;
  #endif
--- 49,55 ----
  #include <sys/socket.h>
  #include <stdlib.h>
  
! #ifdef __STDC__
  struct mbuf;
  struct rtentry;
  #endif
***************
*** 670,676 ****
  #define YYERROR goto yyerrlab
  
  #ifndef YYPARSE_PARAM
! #if defined(__cplusplus) || __STDC__
  #define YYPARSE_PARAM_ARG void
  #define YYPARSE_PARAM_DECL
  #else /* ! ANSI-C/C++ */
--- 670,676 ----
  #define YYERROR goto yyerrlab
  
  #ifndef YYPARSE_PARAM
! #if defined(__cplusplus) || defined(__STDC__)
  #define YYPARSE_PARAM_ARG void
  #define YYPARSE_PARAM_DECL
  #else /* ! ANSI-C/C++ */
***************
*** 681,687 ****
  #ifndef YYPARSE_PARAM_TYPE
  #define YYPARSE_PARAM_TYPE void *
  #endif
! #if defined(__cplusplus) || __STDC__
  #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
  #define YYPARSE_PARAM_DECL
  #else /* ! ANSI-C/C++ */
--- 681,687 ----
  #ifndef YYPARSE_PARAM_TYPE
  #define YYPARSE_PARAM_TYPE void *
  #endif
! #if defined(__cplusplus) || defined(__STDC__)
  #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
  #define YYPARSE_PARAM_DECL
  #else /* ! ANSI-C/C++ */
*** nmap-3.28/libpcap-possiblymodified/grammar.y.orig   Wed Dec 18 01:10:07 2002
--- nmap-3.28/libpcap-possiblymodified/grammar.y        Thu Jun 19 13:54:25 2003
***************
*** 34,40 ****
  #include <sys/socket.h>
  #include <stdlib.h>
  
! #if __STDC__
  struct mbuf;
  struct rtentry;
  #endif
--- 34,40 ----
  #include <sys/socket.h>
  #include <stdlib.h>
  
! #ifdef __STDC__
  struct mbuf;
  struct rtentry;
  #endif

---------------------------------------------------------------------
For help using this (nmap-dev) mailing list, send a blank email to 
nmap-dev-help () insecure org . List run by ezmlm-idx (www.ezmlm.org).

Current thread: