1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-29 00:27:11 +00:00

only try BIOCLOCK against bpf if tcpdump is using bpf.

fixes tcpdump -r pcapfile, which is getting packets from a file,
not the kernel via bpf.

problem found by bluhm@ and regress tests
ok deraadt@
This commit is contained in:
dlg
2025-11-14 21:47:31 +00:00
parent 671962bbd0
commit 8cf7d6358c

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: privsep.c,v 1.58 2025/11/13 20:46:39 deraadt Exp $ */
/* $OpenBSD: privsep.c,v 1.59 2025/11/14 21:47:31 dlg Exp $ */
/*
* Copyright (c) 2003 Can Erkin Acar
@@ -476,7 +476,7 @@ impl_init_done(int fd, int *bpfd)
logmsg(LOG_DEBUG, "[priv]: msg PRIV_INIT_DONE received");
/* lock the descriptor */
if (ioctl(*bpfd, BIOCLOCK, NULL) == -1)
if (*bpfd != -1 && ioctl(*bpfd, BIOCLOCK, NULL) == -1)
err(1, "BIOCLOCK");
ret = 0;