mirror of
https://github.com/nmap/nmap.git
synced 2026-10-21 11:22:05 +00:00
if nse's connect is issued on an open socket, close the old connection before
connecting - this should prevent starvation, in case a single script opens many connections
This commit is contained in:
parent
0012ee3dee
commit
24cca96f14
1 changed files with 12 additions and 1 deletions
13
nse_nsock.cc
13
nse_nsock.cc
|
|
@ -269,7 +269,18 @@ static int l_nsock_connect(lua_State* l) {
|
|||
int error_id;
|
||||
|
||||
l_nsock_clear_buf(l, udata);
|
||||
|
||||
|
||||
if(udata->nsiod!=NULL){
|
||||
/*should a script try to connect a socket, which is already connected
|
||||
* we close the old connection, since it would have no access to it
|
||||
* anyways
|
||||
*/
|
||||
if(o.scriptTrace()){
|
||||
log_write(LOG_STDOUT,"%s: Trying to connect already connected socket - closing!\n",SCRIPT_ENGINE);
|
||||
}
|
||||
l_nsock_close(l);
|
||||
lua_pop(l,1);
|
||||
}
|
||||
error_id = getaddrinfo(addr, NULL, NULL, &dest);
|
||||
if (error_id) {
|
||||
error = gai_strerror(error_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue