mirror of
https://github.com/nmap/nmap.git
synced 2025-12-14 11:49:01 +00:00
This patch fixes a bug reported here [1]. The bug was due to the nsock_yield
struct not being set in any of the pcap functions. Because of this, the callback routines would attempt to use a NULL pointer for the lua_State * and would then SEGFAULT. [1] http://seclists.org/nmap-dev/2009/q2/0180.html
This commit is contained in:
@@ -1240,6 +1240,8 @@ static int l_nsock_ncap_register(lua_State *L){
|
|||||||
TIMEVAL_MSEC_ADD(nr->end_time, now, udata->timeout);
|
TIMEVAL_MSEC_ADD(nr->end_time, now, udata->timeout);
|
||||||
nr->key = strdup(hex((char*)testdata, testdatasz));
|
nr->key = strdup(hex((char*)testdata, testdatasz));
|
||||||
nr->yield = &udata->yield;
|
nr->yield = &udata->yield;
|
||||||
|
udata->yield.thread = L;
|
||||||
|
udata->yield.udata = udata;
|
||||||
nr->ncap_cback_ref = udata->ncap_cback_ref;
|
nr->ncap_cback_ref = udata->ncap_cback_ref;
|
||||||
/* always create new event. */
|
/* always create new event. */
|
||||||
nr->nseid = nsock_pcap_read_packet(nsp,
|
nr->nseid = nsock_pcap_read_packet(nsp,
|
||||||
@@ -1273,6 +1275,8 @@ int l_nsock_pcap_receive(lua_State *L){
|
|||||||
* udata during this request */
|
* udata during this request */
|
||||||
struct ncap_request *nr = udata->ncap_request;
|
struct ncap_request *nr = udata->ncap_request;
|
||||||
udata->ncap_request = NULL;
|
udata->ncap_request = NULL;
|
||||||
|
udata->yield.thread = L;
|
||||||
|
udata->yield.udata = udata;
|
||||||
|
|
||||||
/* ready to receive data? don't suspend thread*/
|
/* ready to receive data? don't suspend thread*/
|
||||||
if(nr->received) /*data already received*/
|
if(nr->received) /*data already received*/
|
||||||
@@ -1281,7 +1285,6 @@ int l_nsock_pcap_receive(lua_State *L){
|
|||||||
/* no data yet? suspend thread */
|
/* no data yet? suspend thread */
|
||||||
nr->suspended = 1;
|
nr->suspended = 1;
|
||||||
|
|
||||||
udata->yield.thread = L;
|
|
||||||
return lua_yield(L, 0);
|
return lua_yield(L, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user