mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Clean up immediately and avoid pcap garbage collection if opening fails
This commit is contained in:
parent
fe9a1db4dd
commit
840af24083
1 changed files with 7 additions and 5 deletions
12
nse_nsock.cc
12
nse_nsock.cc
|
|
@ -1019,16 +1019,18 @@ static int l_pcap_open (lua_State *L)
|
|||
|
||||
lua_pop(L, 1); /* the nonexistant socket */
|
||||
nsiod = (nsock_iod *) lua_newuserdata(L, sizeof(nsock_iod));
|
||||
*nsiod = nsock_iod_new(nsp, nu);
|
||||
rc = nsock_pcap_open(nsp, *nsiod, lua_tostring(L, 6), snaplen,
|
||||
lua_toboolean(L, 4), bpf);
|
||||
if (rc) {
|
||||
nsock_iod_delete(*nsiod, NSOCK_PENDING_ERROR);
|
||||
luaL_error(L, "can't open pcap reader on %s", device);
|
||||
}
|
||||
lua_pushvalue(L, PCAP_SOCKET);
|
||||
lua_setmetatable(L, -2);
|
||||
*nsiod = nsock_iod_new(nsp, nu);
|
||||
lua_pushvalue(L, 7); /* the pcap socket key */
|
||||
lua_pushvalue(L, -2); /* the pcap socket nsiod */
|
||||
lua_rawset(L, KEY_PCAP); /* KEY_PCAP["dev|snap|promis|bpf"] = pcap_nsiod */
|
||||
rc = nsock_pcap_open(nsp, *nsiod, lua_tostring(L, 6), snaplen,
|
||||
lua_toboolean(L, 4), bpf);
|
||||
if (rc)
|
||||
luaL_error(L, "can't open pcap reader on %s", device);
|
||||
}
|
||||
lua_getuservalue(L, 1); /* the socket user value */
|
||||
lua_pushvalue(L, -2); /* the pcap socket nsiod */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue