aboutsummaryrefslogtreecommitdiff
path: root/pcap-netfilter-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2023-06-25 09:05:32 -0700
committerGitHub <noreply@github.com>2023-06-25 09:05:32 -0700
commita6a998858e522b158e2d8a27302f14a4d6bf214e (patch)
tree52c8f4835f8ff0ff4c854f5e3c5757020b04caf2 /pcap-netfilter-linux.c
parentd130479e5b2c024a70e1f7446a228eb19243114e (diff)
parent8f1f6fcbe4b4c17d965b42374a2f170452a93289 (diff)
Merge pull request #1201 from guyharris/fail-if-cant-allocate-dlt-list
If we can't allocate a DLT_ list, fail.
Diffstat (limited to 'pcap-netfilter-linux.c')
-rw-r--r--pcap-netfilter-linux.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/pcap-netfilter-linux.c b/pcap-netfilter-linux.c
index 23475aed..cfad2523 100644
--- a/pcap-netfilter-linux.c
+++ b/pcap-netfilter-linux.c
@@ -613,12 +613,15 @@ netfilter_activate(pcap_t* handle)
if (type == NFLOG) {
handle->linktype = DLT_NFLOG;
handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
- if (handle->dlt_list != NULL) {
- handle->dlt_list[0] = DLT_NFLOG;
- handle->dlt_list[1] = DLT_IPV4;
- handle->dlt_count = 2;
+ if (handle->dlt_list == NULL) {
+ pcap_fmt_errmsg_for_errno(handle->errbuf,
+ PCAP_ERRBUF_SIZE, errno,
+ "Can't allocate DLT list");
+ goto close_fail;
}
-
+ handle->dlt_list[0] = DLT_NFLOG;
+ handle->dlt_list[1] = DLT_IPV4;
+ handle->dlt_count = 2;
} else
handle->linktype = DLT_IPV4;