node_pcap
node_pcap copied to clipboard
Segmentation fault
Dear,
I am having a similar issue to Issue #113
I have done your suggestions and it looks a little like this:
~/node_modules/pcap master ● sudo ~/node_modules/pcap/examples/simple_capture en6 "" libpcap version 1.6.2 Key: addr address: fe80::384d:550d:e25d:702d Key: netmask address: ffff:ffff:ffff:ffff:: Key: broadaddr Key: dstaddr address: (null)
My ifconfig can be seen here: https://gist.github.com/SteveClement/d5664765b2a22660fbd5
I also compiled it with that latest libpcap (thought that might fix it) but it really looks like it cannot handle one of the devices it tries to enumerate.
cheers.
Same issue here. Here is an ifconfig. Can't figure out exactly why this is happening.
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 0c:4d:e9:c0:ef:ec
inet6 fe80::e4d:e9ff:fec0:efec%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.123 netmask 0xffff0000 broadcast 192.168.255.255
nd6 options=1<PERFORMNUD>
media: autoselect (1000baseT <full-duplex,flow-control,energy-efficient-ethernet>)
status: active
en1: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
ether 88:63:df:a8:03:87
nd6 options=1<PERFORMNUD>
media: autoselect (<unknown type>)
status: inactive
en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:1c:36:00:00
media: autoselect <full-duplex>
status: inactive
en3: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:1c:36:00:01
media: autoselect <full-duplex>
status: inactive
p2p0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 2304
ether 0a:63:df:a8:03:87
media: autoselect
status: inactive
awdl0: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether 06:f2:77:ef:74:95
nd6 options=1<PERFORMNUD>
media: autoselect
status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 0e:4d:e9:0c:12:00
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 6 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 7 priority 0 path cost 0
nd6 options=1<PERFORMNUD>
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
inet6 fe80::df5e:d57c:c09f:637%utun0 prefixlen 64 scopeid 0xb
nd6 options=1<PERFORMNUD>
From what I see, it is failing on the utun0 device. More specifically, with the inet_ntop return value. I noticed that @SteveClement also has a device with the same name.
Edit: Upon further inspection, when processing utun0, the cur_dev->dstaddr is a non-null pointer, where as for the rest of the devices, cur_dev->dstaddr is just equal to 0.
Haven't followed up on this one. Have you tried to destroy utun0 and launch again?
I haven't done that. However, modifying the pcap_binding.cc at line 32 fixes the issue.
Original Way
const char* address = inet_ntop(addr->sa_family, src, dst_addr, size);
Address->Set(Nan::New(key).ToLocalChecked(), Nan::New(address).ToLocalChecked());
Modified Way
const char* address = inet_ntop(addr->sa_family, src, dst_addr, size);
if (address) {
Address->Set(Nan::New(key).ToLocalChecked(), Nan::New(address).ToLocalChecked());
}
src is coming in as an empty string. When you pass an empty string to inet_ntop, it's return value is null, and it doesn't change dst_addr. I'm going to create a pull request with this fix unless someone thinks I'm missing something.
EDIT: utun0 is created by "Back To My Mac" in OS X. You can turn this service off to bring the interface down if you want.