mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Have NetBlock::next return the socklen.
This matters on OS X; with the wrong size, connect scans give "Invalid argument". Reported by Jesper Kückelhahn. http://seclists.org/nmap-dev/2013/q1/84
This commit is contained in:
@@ -278,7 +278,7 @@ NetBlockIPv4Ranges::NetBlockIPv4Ranges() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetBlockIPv4Ranges::next(struct sockaddr_storage *ss) {
|
bool NetBlockIPv4Ranges::next(struct sockaddr_storage *ss, size_t *sslen) {
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -303,6 +303,7 @@ bool NetBlockIPv4Ranges::next(struct sockaddr_storage *ss) {
|
|||||||
sin->sin_len = sizeof(*sin);
|
sin->sin_len = sizeof(*sin);
|
||||||
#endif
|
#endif
|
||||||
sin->sin_addr.s_addr = htonl((this->counter[0] << 24) | (this->counter[1] << 16) | (this->counter[2] << 8) | this->counter[3]);
|
sin->sin_addr.s_addr = htonl((this->counter[0] << 24) | (this->counter[1] << 16) | (this->counter[2] << 8) | this->counter[3]);
|
||||||
|
*sslen = sizeof(*sin);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
bool carry;
|
bool carry;
|
||||||
@@ -451,7 +452,7 @@ static bool ipv6_equal(const struct in6_addr *a, const struct in6_addr *b) {
|
|||||||
return memcmp(a->s6_addr, b->s6_addr, 16) == 0;
|
return memcmp(a->s6_addr, b->s6_addr, 16) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetBlockIPv6Netmask::next(struct sockaddr_storage *ss) {
|
bool NetBlockIPv6Netmask::next(struct sockaddr_storage *ss, size_t *sslen) {
|
||||||
struct sockaddr_in6 *sin6;
|
struct sockaddr_in6 *sin6;
|
||||||
|
|
||||||
if (this->exhausted)
|
if (this->exhausted)
|
||||||
@@ -463,6 +464,7 @@ bool NetBlockIPv6Netmask::next(struct sockaddr_storage *ss) {
|
|||||||
#ifdef SIN_LEN
|
#ifdef SIN_LEN
|
||||||
sin6->sin6_len = sizeof(*sin6);
|
sin6->sin6_len = sizeof(*sin6);
|
||||||
#endif
|
#endif
|
||||||
|
*sslen = sizeof(*sin6);
|
||||||
|
|
||||||
if (this->addr.sin6_scope_id != 0)
|
if (this->addr.sin6_scope_id != 0)
|
||||||
sin6->sin6_scope_id = this->addr.sin6_scope_id;
|
sin6->sin6_scope_id = this->addr.sin6_scope_id;
|
||||||
@@ -631,7 +633,7 @@ NetBlockHostname::NetBlockHostname(const char *hostname, int af) {
|
|||||||
this->bits = -1;
|
this->bits = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetBlockHostname::next(struct sockaddr_storage *ss) {
|
bool NetBlockHostname::next(struct sockaddr_storage *ss, size_t *sslen) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
bool is_resolved_address(const struct sockaddr_storage *ss) const;
|
bool is_resolved_address(const struct sockaddr_storage *ss) const;
|
||||||
|
|
||||||
virtual bool next(struct sockaddr_storage *ss) = 0;
|
virtual bool next(struct sockaddr_storage *ss, size_t *sslen) = 0;
|
||||||
virtual void apply_netmask(int bits) = 0;
|
virtual void apply_netmask(int bits) = 0;
|
||||||
virtual std::string str() const = 0;
|
virtual std::string str() const = 0;
|
||||||
};
|
};
|
||||||
@@ -137,7 +137,7 @@ public:
|
|||||||
|
|
||||||
NetBlockIPv4Ranges();
|
NetBlockIPv4Ranges();
|
||||||
|
|
||||||
bool next(struct sockaddr_storage *ss);
|
bool next(struct sockaddr_storage *ss, size_t *sslen);
|
||||||
void apply_netmask(int bits);
|
void apply_netmask(int bits);
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class NetBlockIPv6Netmask : public NetBlock {
|
|||||||
public:
|
public:
|
||||||
void set_addr(const struct sockaddr_in6 *addr);
|
void set_addr(const struct sockaddr_in6 *addr);
|
||||||
|
|
||||||
bool next(struct sockaddr_storage *ss);
|
bool next(struct sockaddr_storage *ss, size_t *sslen);
|
||||||
void apply_netmask(int bits);
|
void apply_netmask(int bits);
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
|
|
||||||
NetBlock *resolve() const;
|
NetBlock *resolve() const;
|
||||||
|
|
||||||
bool next(struct sockaddr_storage *ss);
|
bool next(struct sockaddr_storage *ss, size_t *sslen);
|
||||||
void apply_netmask(int bits);
|
void apply_netmask(int bits);
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -353,8 +353,7 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) {
|
|||||||
delete netblock_hostname;
|
delete netblock_hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
*sslen = sizeof(*ss);
|
if (this->netblock->next(ss, sslen))
|
||||||
if (this->netblock->next(ss))
|
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user