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

[Bug] Didn't use pcap_freecode to free the bpf_program struct generated by pcap_compile #572

Closed
lvtao-sec opened this issue Dec 28, 2019 · 1 comment
Assignees
Labels

Comments

@lvtao-sec
Copy link

Describe the bug
The code of current version 1150736 at the following locations didn't free the bpf_pgrogram structure generated by pcap_compile:

src/tcpprep.c:139:        if (pcap_compile(options->pcap, &options->bpf.program, options->bpf.filter,
src/tcpliveplay.c:662:    if (pcap_compile(handle, &fp, filter_exp, 0, net) == -1) {
src/tcpliveplay.c:697:    if (pcap_compile(handle, &fp, filter_exp, 0, net) == -1) {
src/bridge.c:209:        if (pcap_compile(options->pcap1, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) {
src/bridge.c:220:            if (pcap_compile(options->pcap2, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) {

The document of libpcap said : pcap_freecode() is used to free up allocated memory pointed to by a bpf_program struct generated by pcap_compile(3PCAP) when that BPF program is no longer needed, for example after it has been made the filter program for a pcap structure by a call to pcap_setfilter(3PCAP)

So patch those code with pcap_freecode API.

@fklassen fklassen self-assigned this May 8, 2020
@fklassen fklassen added the bug label May 8, 2020
fklassen added a commit that referenced this issue Jun 3, 2020
Bug #572 add pcap_freecode() after pcap_compile()
@fklassen
Copy link
Member

fklassen commented Jun 3, 2020

Fixed in PR #598

@fklassen fklassen closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants