Attempt to fix crash in test mode

This commit is contained in:
Petr Menšík 2023-07-23 15:47:15 +02:00
parent 0851ede00a
commit 7949057726
2 changed files with 32 additions and 1 deletions

27
dhcpcd-10.0.2-test.patch Normal file
View File

@ -0,0 +1,27 @@
From 5836269b2a1ba55ba9b0f2efdbc4fdca4853d452 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Sun, 23 Jul 2023 15:44:32 +0200
Subject: [PATCH] Do not crash on dhcpcd test run
Check if state->bpf is allocated before attempting to write there.
---
src/dhcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/dhcp.c b/src/dhcp.c
index edd1c01..e029cee 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -3314,7 +3314,8 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
state->reason = "TEST";
script_runreason(ifp, state->reason);
eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
- state->bpf->bpf_flags |= BPF_EOF;
+ if (state->bpf)
+ state->bpf->bpf_flags |= BPF_EOF;
return;
}
eloop_timeout_delete(ifp->ctx->eloop, send_discover, ifp);
--
2.41.0

View File

@ -14,6 +14,10 @@ Source2: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xa785ed2755955d9
Source3: %{name}.service
Source4: %{name}@.service
Source5: systemd-sysusers.conf
# https://github.com/NetworkConfiguration/dhcpcd/pull/231
Patch1: dhcpcd-10.0.2-test.patch
BuildRequires: gcc
BuildRequires: systemd-rpm-macros
BuildRequires: chrony
@ -33,7 +37,7 @@ through NDP, DHCPv4 and DHCPv6 protocols.
%if 0%{?fedora} || 0%{?rhel} > 8
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%endif
%autosetup
%autosetup -p1
%build
%configure \