summaryrefslogtreecommitdiffstats
path: root/lib/libpcap/gencode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpcap/gencode.c')
-rw-r--r--lib/libpcap/gencode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libpcap/gencode.c b/lib/libpcap/gencode.c
index a9fb14be943..5018b52266c 100644
--- a/lib/libpcap/gencode.c
+++ b/lib/libpcap/gencode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gencode.c,v 1.56 2020/09/12 09:27:22 kn Exp $ */
+/* $OpenBSD: gencode.c,v 1.57 2021/01/18 09:26:35 sthen Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
@@ -3103,6 +3103,13 @@ gen_broadcast(proto)
break;
case Q_IP:
+ /*
+ * We treat a netmask of PCAP_NETMASK_UNKNOWN (0xffffffff)
+ * as an indication that we don't know the netmask, and fail
+ * in that case.
+ */
+ if (netmask == PCAP_NETMASK_UNKNOWN)
+ bpf_error("netmask not known, so 'ip broadcast' not supported");
b0 = gen_linktype(ETHERTYPE_IP);
hostmask = ~netmask;
b1 = gen_mcmp_nl(16, BPF_W, (bpf_int32)0, hostmask);