Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sometime pcap_next returns 0 which lead to segment fault #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AntsKnows
Copy link

Meet a segmentation fault situation:
Thread 2 "boopkit" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7cc2700 (LWP 936627)]
0x00000000003100d9 in xcap (v_dev_name=0x315f68 <cfg+12292>) at dpi.c:217
217 ether_type = ntohs(ep->ether_type);
(gdb) bt
#0 0x00000000003100d9 in xcap (v_dev_name=0x315f68 <cfg+12292>) at dpi.c:217
#1 0x00007ffff7ede609 in start_thread (arg=) at pthread_create.c:477
#2 0x00007ffff7e03133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) p ep
$1 = (struct ether_header *) 0x0
(gdb) p packet
$2 = (const u_char *) 0x0

According to man pcap_next():
pcap_next() returns a pointer to the packet data on success, and
returns NULL if an error occured, or if no packets were read from a
live capture (if, for example, they were discarded because they didn't
pass the packet filter, or if, on platforms that support a read timeout
that starts before any packets arrive, the timeout expires before any
packets arrive, or if the file descriptor for the capture device is in
non-blocking mode and no packets were available to be read), or if no
more packets are available in a ``savefile.'' Unfortunately, there is
no way to determine whether an error occured or not.

pcap_next() may returns NULL. So bybass it to avoid segmentation fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant