mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Return -1 instead of calling pfatal in nmap_raw_socket.
There was one case where we previously didn't fatal, in nse_dnet.cc. Move the fatal calls out of nmap_raw_socket and into the calling scope, with the exception of the one in nse_dnet.cc. The problem was reported by Rob Nicholls. http://seclists.org/nmap-dev/2012/q4/186
This commit is contained in:
@@ -187,6 +187,8 @@ void FPNetworkControl::init(const char *ifname, devtype iftype) {
|
|||||||
if (this->rawsd >= 0)
|
if (this->rawsd >= 0)
|
||||||
close(this->rawsd);
|
close(this->rawsd);
|
||||||
rawsd = nmap_raw_socket(ifname);
|
rawsd = nmap_raw_socket(ifname);
|
||||||
|
if (rawsd < 0)
|
||||||
|
pfatal("Couldn't obtain raw socket in %s", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* De-register existing callers */
|
/* De-register existing callers */
|
||||||
|
|||||||
@@ -383,6 +383,8 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName,
|
|||||||
proxy->ethptr = &proxy->eth;
|
proxy->ethptr = &proxy->eth;
|
||||||
} else {
|
} else {
|
||||||
proxy->rawsd = nmap_raw_socket(proxy->host.deviceName());
|
proxy->rawsd = nmap_raw_socket(proxy->host.deviceName());
|
||||||
|
if (proxy->rawsd < 0)
|
||||||
|
pfatal("socket troubles in %s", __func__);
|
||||||
unblock_socket(proxy->rawsd);
|
unblock_socket(proxy->rawsd);
|
||||||
proxy->eth.ethsd = NULL;
|
proxy->eth.ethsd = NULL;
|
||||||
proxy->ethptr = NULL;
|
proxy->ethptr = NULL;
|
||||||
|
|||||||
@@ -1268,6 +1268,8 @@ HostOsScan::HostOsScan(Target *t) {
|
|||||||
rawsd = -1;
|
rawsd = -1;
|
||||||
} else {
|
} else {
|
||||||
rawsd = nmap_raw_socket(t->deviceName());
|
rawsd = nmap_raw_socket(t->deviceName());
|
||||||
|
if (rawsd < 0)
|
||||||
|
pfatal("socket troubles in %s", __func__);
|
||||||
unblock_socket(rawsd);
|
unblock_socket(rawsd);
|
||||||
ethsd = NULL;
|
ethsd = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1662,6 +1662,8 @@ void UltraScanInfo::Init(std::vector<Target *> &Targets, struct scan_lists *pts,
|
|||||||
rawsd = -1;
|
rawsd = -1;
|
||||||
} else {
|
} else {
|
||||||
rawsd = nmap_raw_socket(Targets[0]->deviceName());
|
rawsd = nmap_raw_socket(Targets[0]->deviceName());
|
||||||
|
if (rawsd < 0)
|
||||||
|
pfatal("socket troubles in %s", __func__);
|
||||||
/* We do not wan't to unblock the socket since we want to wait
|
/* We do not wan't to unblock the socket since we want to wait
|
||||||
if kernel send buffers fill up rather than get ENOBUF, and
|
if kernel send buffers fill up rather than get ENOBUF, and
|
||||||
we won't be receiving on the socket anyway
|
we won't be receiving on the socket anyway
|
||||||
|
|||||||
5
tcpip.cc
5
tcpip.cc
@@ -155,8 +155,9 @@ int nmap_raw_socket(const char *warning_device_name) {
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
win32_fatal_raw_sockets(warning_device_name);
|
win32_fatal_raw_sockets(warning_device_name);
|
||||||
#endif
|
#endif
|
||||||
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
|
||||||
pfatal("socket troubles in %s", __func__);
|
if (rawsd < 0)
|
||||||
|
return rawsd;
|
||||||
broadcast_socket(rawsd);
|
broadcast_socket(rawsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
sethdrinclude(rawsd);
|
sethdrinclude(rawsd);
|
||||||
|
|||||||
@@ -879,6 +879,8 @@ TracerouteState::TracerouteState(std::vector<Target *> &targets) {
|
|||||||
rawsd = -1;
|
rawsd = -1;
|
||||||
} else {
|
} else {
|
||||||
rawsd = nmap_raw_socket(targets[0]->deviceName());
|
rawsd = nmap_raw_socket(targets[0]->deviceName());
|
||||||
|
if (rawsd < 0)
|
||||||
|
pfatal("traceroute: socket troubles");
|
||||||
ethsd = NULL;
|
ethsd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user