Skip to content

Commit 41dadae

Browse files
author
david
committed
Use socklen_t as the type in arguments to getsockname and getsockopt to
avoid a "pointer targets differ in signedness" warning. Add a check for socklen_t in configure.in; if it's not present, typedef it to int.
1 parent 3f37e4f commit 41dadae

File tree

7 files changed

+124
-2
lines changed

7 files changed

+124
-2
lines changed

libdnet-stripped/NMAP_MODIFICATIONS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ o Added libdnet-stripped.vcproj -- A Visual Studio.Net project file
3131
o Regenerated build files with Autoconf 2.63, Automake 1.10.1, and
3232
libtool 2.2.6.
3333

34+
o Added a check for socklen_t in configure.in and used socklen_t when
35+
calling getsockname and getsockopt to avoid a "pointer targets differ
36+
in signedness" warning on platforms where socklen_t is unsigned.
37+
3438
o Made some code changes to intf.c (the patch below). This does the following:
3539

3640
o Preserve the alias qualifier from interface name in more cases

libdnet-stripped/acconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ int strlcpy(char *, const char *, int);
3030
#ifndef HAVE_STRSEP
3131
char *strsep(char **, const char *);
3232
#endif
33+
34+
#ifndef HAVE_SOCKLEN_T
35+
typedef socklen_t int
36+
#endif

libdnet-stripped/configure

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14021,6 +14021,111 @@ fi
1402114021
if test "$GCC" = yes ; then
1402214022
CFLAGS="$CFLAGS -Wall"
1402314023
fi
14024+
{ $as_echo "$as_me:$LINENO: checking for socklen_t" >&5
14025+
$as_echo_n "checking for socklen_t... " >&6; }
14026+
if test "${ac_cv_type_socklen_t+set}" = set; then
14027+
$as_echo_n "(cached) " >&6
14028+
else
14029+
ac_cv_type_socklen_t=no
14030+
cat >conftest.$ac_ext <<_ACEOF
14031+
/* confdefs.h. */
14032+
_ACEOF
14033+
cat confdefs.h >>conftest.$ac_ext
14034+
cat >>conftest.$ac_ext <<_ACEOF
14035+
/* end confdefs.h. */
14036+
#include <sys/socket.h>
14037+
14038+
int
14039+
main ()
14040+
{
14041+
if (sizeof (socklen_t))
14042+
return 0;
14043+
;
14044+
return 0;
14045+
}
14046+
_ACEOF
14047+
rm -f conftest.$ac_objext
14048+
if { (ac_try="$ac_compile"
14049+
case "(($ac_try" in
14050+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14051+
*) ac_try_echo=$ac_try;;
14052+
esac
14053+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
14054+
$as_echo "$ac_try_echo") >&5
14055+
(eval "$ac_compile") 2>conftest.er1
14056+
ac_status=$?
14057+
grep -v '^ *+' conftest.er1 >conftest.err
14058+
rm -f conftest.er1
14059+
cat conftest.err >&5
14060+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
14061+
(exit $ac_status); } && {
14062+
test -z "$ac_c_werror_flag" ||
14063+
test ! -s conftest.err
14064+
} && test -s conftest.$ac_objext; then
14065+
cat >conftest.$ac_ext <<_ACEOF
14066+
/* confdefs.h. */
14067+
_ACEOF
14068+
cat confdefs.h >>conftest.$ac_ext
14069+
cat >>conftest.$ac_ext <<_ACEOF
14070+
/* end confdefs.h. */
14071+
#include <sys/socket.h>
14072+
14073+
int
14074+
main ()
14075+
{
14076+
if (sizeof ((socklen_t)))
14077+
return 0;
14078+
;
14079+
return 0;
14080+
}
14081+
_ACEOF
14082+
rm -f conftest.$ac_objext
14083+
if { (ac_try="$ac_compile"
14084+
case "(($ac_try" in
14085+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14086+
*) ac_try_echo=$ac_try;;
14087+
esac
14088+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
14089+
$as_echo "$ac_try_echo") >&5
14090+
(eval "$ac_compile") 2>conftest.er1
14091+
ac_status=$?
14092+
grep -v '^ *+' conftest.er1 >conftest.err
14093+
rm -f conftest.er1
14094+
cat conftest.err >&5
14095+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
14096+
(exit $ac_status); } && {
14097+
test -z "$ac_c_werror_flag" ||
14098+
test ! -s conftest.err
14099+
} && test -s conftest.$ac_objext; then
14100+
:
14101+
else
14102+
$as_echo "$as_me: failed program was:" >&5
14103+
sed 's/^/| /' conftest.$ac_ext >&5
14104+
14105+
ac_cv_type_socklen_t=yes
14106+
fi
14107+
14108+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14109+
else
14110+
$as_echo "$as_me: failed program was:" >&5
14111+
sed 's/^/| /' conftest.$ac_ext >&5
14112+
14113+
14114+
fi
14115+
14116+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14117+
fi
14118+
{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5
14119+
$as_echo "$ac_cv_type_socklen_t" >&6; }
14120+
if test "x$ac_cv_type_socklen_t" = x""yes; then
14121+
14122+
cat >>confdefs.h <<_ACEOF
14123+
#define HAVE_SOCKLEN_T 1
14124+
_ACEOF
14125+
14126+
14127+
fi
14128+
1402414129
1402514130
{ $as_echo "$as_me:$LINENO: checking for working memcmp" >&5
1402614131
$as_echo_n "checking for working memcmp... " >&6; }

libdnet-stripped/configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ AC_PROG_GCC_TRADITIONAL
194194
if test "$GCC" = yes ; then
195195
CFLAGS="$CFLAGS -Wall"
196196
fi
197+
AC_CHECK_TYPES([socklen_t], [], [], [#include <sys/socket.h>])
197198

198199
dnl Checks for library functions.
199200
AC_FUNC_MEMCMP

libdnet-stripped/include/config.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@
142142
/* Define if sockaddr struct has sa_len. */
143143
#undef HAVE_SOCKADDR_SA_LEN
144144

145+
/* Define to 1 if the system has the type `socklen_t'. */
146+
#undef HAVE_SOCKLEN_T
147+
145148
/* Define to 1 if you have the <stdint.h> header file. */
146149
#undef HAVE_STDINT_H
147150

@@ -296,3 +299,7 @@ int strlcpy(char *, const char *, int);
296299
#ifndef HAVE_STRSEP
297300
char *strsep(char **, const char *);
298301
#endif
302+
303+
#ifndef HAVE_SOCKLEN_T
304+
typedef socklen_t int
305+
#endif

libdnet-stripped/src/intf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ int
634634
intf_get_dst(intf_t *intf, struct intf_entry *entry, struct addr *dst)
635635
{
636636
struct sockaddr_in sin;
637-
int n;
637+
socklen_t n;
638638

639639
if (dst->addr_type != ADDR_TYPE_IP) {
640640
errno = EINVAL;

libdnet-stripped/src/ip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ ip_t *
2626
ip_open(void)
2727
{
2828
ip_t *i;
29-
int n, len;
29+
int n;
30+
socklen_t len;
3031

3132
if ((i = calloc(1, sizeof(*i))) == NULL)
3233
return (NULL);

0 commit comments

Comments
 (0)