aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-11-25 18:07:48 -0800
committerGuy Harris <guy@alum.mit.edu>2018-11-25 18:07:48 -0800
commit72518d2625584cb60109060b11876dfc93c56252 (patch)
tree4f00c1a97ecb14b96f29bafdae82726d43b28d0e /pcap-linux.c
parent6c7c08fc0ad3d287729011396293f44956a2bbb1 (diff)
With PF_INET/SOCK_PACKET sockets, check up front for the "any" device.
Those sockets must be bound to an interface, so they can't support the "any" device; check for the "any" device, and fail if we're trying to open that device, before we even create the socket.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 6781b3bc..4afb397c 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -6860,8 +6860,17 @@ activate_old(pcap_t *handle)
struct utsname utsname;
int mtu;
- /* Open the socket */
+ /*
+ * PF_INET/SOCK_PACKET sockets must be bound to a device, so we
+ * can't support the "any" device.
+ */
+ if (strcmp(device, "any") == 0) {
+ pcap_strlcpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
+ PCAP_ERRBUF_SIZE);
+ return PCAP_ERROR;
+ }
+ /* Open the socket */
handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
if (handle->fd == -1) {
err = errno;
@@ -6888,12 +6897,6 @@ activate_old(pcap_t *handle)
handlep->cooked = 0;
/* Bind to the given device */
-
- if (strcmp(device, "any") == 0) {
- pcap_strlcpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
- PCAP_ERRBUF_SIZE);
- return PCAP_ERROR;
- }
if (iface_bind_old(handle->fd, device, handle->errbuf) == -1)
return PCAP_ERROR;