mirror of
https://github.com/nmap/nmap.git
synced 2026-08-27 11:55:27 +00:00
Merge d0fa89658c into d233b45684
This commit is contained in:
commit
81a54c440d
3 changed files with 32 additions and 0 deletions
16
nse_nsock.cc
16
nse_nsock.cc
|
|
@ -425,6 +425,14 @@ static nse_nsock_udata *check_nsock_udata (lua_State *L, int idx, bool open)
|
|||
if (nu->source_addr.ss_family != AF_UNSPEC) {
|
||||
nsock_iod_set_localaddr(nu->nsiod, &nu->source_addr, nu->source_addrlen);
|
||||
} else if (0 == o.SourceSockAddr(&ss, &sslen)) {
|
||||
// Use the exact protocol-specific length. Some platforms (e.g. FreeBSD)
|
||||
// reject sizeof(sockaddr_storage) passed to bind() with EINVAL.
|
||||
if (ss.ss_family == AF_INET)
|
||||
sslen = sizeof(struct sockaddr_in);
|
||||
#if HAVE_IPV6
|
||||
else if (ss.ss_family == AF_INET6)
|
||||
sslen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
nsock_iod_set_localaddr(nu->nsiod, &ss, sslen);
|
||||
}
|
||||
if (o.ipoptionslen)
|
||||
|
|
@ -548,6 +556,14 @@ static int connect (lua_State *L, int status, lua_KContext ctx)
|
|||
if (nu->source_addr.ss_family != AF_UNSPEC) {
|
||||
nsock_iod_set_localaddr(nu->nsiod, &nu->source_addr, nu->source_addrlen);
|
||||
} else if (0 == o.SourceSockAddr(&ss, &sslen)) {
|
||||
// Use the exact protocol-specific length. Some platforms (e.g. FreeBSD)
|
||||
// reject sizeof(sockaddr_storage) passed to bind() with EINVAL.
|
||||
if (ss.ss_family == AF_INET)
|
||||
sslen = sizeof(struct sockaddr_in);
|
||||
#if HAVE_IPV6
|
||||
else if (ss.ss_family == AF_INET6)
|
||||
sslen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
nsock_iod_set_localaddr(nu->nsiod, &ss, sslen);
|
||||
}
|
||||
if (o.ipoptionslen)
|
||||
|
|
|
|||
|
|
@ -434,6 +434,14 @@ static void init_socket(int sd, const HostScanStats *hss, UltraScanInfo *USI) {
|
|||
#endif
|
||||
|
||||
if (!bind_failed && 0 == o.SourceSockAddr(&ss, &sslen)) {
|
||||
// Use the exact protocol-specific length. Some platforms (e.g. FreeBSD)
|
||||
// reject sizeof(sockaddr_storage) passed to bind() with EINVAL.
|
||||
if (ss.ss_family == AF_INET)
|
||||
sslen = sizeof(struct sockaddr_in);
|
||||
#if HAVE_IPV6
|
||||
else if (ss.ss_family == AF_INET6)
|
||||
sslen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
if (::bind(sd, (struct sockaddr*)&ss, sslen) != 0) {
|
||||
error("%s: Problem binding source address (%s), errno: %d", __func__, inet_socktop_safe(&ss), socket_errno());
|
||||
perror("bind");
|
||||
|
|
|
|||
|
|
@ -2137,6 +2137,14 @@ static void startNextProbe(nsock_pool nsp, nsock_iod nsi, ServiceGroup *SG,
|
|||
fatal("Failed to allocate Nsock I/O descriptor in %s()", __func__);
|
||||
}
|
||||
if (0 == svc->target->SourceSockAddr(&ss, &ss_len)) {
|
||||
// Use the exact protocol-specific length. Some platforms (e.g. FreeBSD)
|
||||
// reject sizeof(sockaddr_storage) passed to bind() with EINVAL.
|
||||
if (ss.ss_family == AF_INET)
|
||||
ss_len = sizeof(struct sockaddr_in);
|
||||
#if HAVE_IPV6
|
||||
else if (ss.ss_family == AF_INET6)
|
||||
ss_len = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
nsock_iod_set_localaddr(svc->niod, &ss, ss_len);
|
||||
}
|
||||
if (o.ipoptionslen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue