Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
rpcapd: Refine SSL options in printusage().
Fix a possible buffer overflow (Coverity CID 1619148).
Fix parameter name validation in the configuration file.
Fix a memory leak in daemon_unpackapplyfilter() (Coverity CID
1641537).
Documentation:
Add a README.hurd.md file.
Cross-reference some man pages better.
Expand Down
19 changes: 14 additions & 5 deletions rpcapd/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,7 @@ daemon_unpackapplyfilter(PCAP_SOCKET sockctrl, SSL *ctrl_ssl, struct session *se
struct bpf_insn *bf_insn;
struct bpf_program bf_prog;
unsigned int i;
int ret;

status = rpcapd_recv(sockctrl, ctrl_ssl, (char *) &filter,
sizeof(struct rpcap_filter), plenp, errmsgbuf);
Expand Down Expand Up @@ -2385,11 +2386,13 @@ daemon_unpackapplyfilter(PCAP_SOCKET sockctrl, SSL *ctrl_ssl, struct session *se
sizeof(struct rpcap_filterbpf_insn), plenp, errmsgbuf);
if (status == -1)
{
return -1;
ret = -1;
goto cleanup;
}
if (status == -2)
{
return -2;
ret = -2;
goto cleanup;
}

bf_insn->code = ntohs(insn.code);
Expand All @@ -2406,16 +2409,22 @@ daemon_unpackapplyfilter(PCAP_SOCKET sockctrl, SSL *ctrl_ssl, struct session *se
if (bpf_validate(bf_prog.bf_insns, bf_prog.bf_len) == 0)
{
snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "The filter contains invalid instructions");
return -2;
ret = -2;
goto cleanup;
}

if (pcap_setfilter(session->fp, &bf_prog))
{
snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "RPCAP error: %s", pcap_geterr(session->fp));
return -2;
ret = -2;
goto cleanup;
}

return 0;
ret = 0;

cleanup:
free(bf_prog.bf_insns);
return ret;
}

static int
Expand Down