From c5362b97447319133098b1114975f1de88961da2 Mon Sep 17 00:00:00 2001 From: renmingshuai Date: Mon, 7 Feb 2022 21:48:30 +0800 Subject: [PATCH] fix coredump when client active is NULL (cherry picked from commit 174b1aced9ba6a7a8e08e36653c0da9dadbab4e5) --- dhcp.spec | 9 ++- fix-coredump-when-client-active-is-NULL.patch | 67 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 fix-coredump-when-client-active-is-NULL.patch diff --git a/dhcp.spec b/dhcp.spec index 6ff59cd..8ce5fc1 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -3,7 +3,7 @@ Name: dhcp Version: 4.4.2 -Release: 9 +Release: 10 Summary: Dynamic host configuration protocol software #Please don't change the epoch on this package Epoch: 12 @@ -56,6 +56,7 @@ Patch33: bugfix-dhcp-64-bit-lease-parse.patch Patch35: backport-CVE-2021-25217.patch Patch36: fix-multiple-definition-with-gcc-10-1.patch Patch37: fix-multiple-definition-with-gcc-10-2.patch +Patch38: fix-coredump-when-client-active-is-NULL.patch BuildRequires: gcc autoconf automake libtool openldap-devel krb5-devel libcap-ng-devel BuildRequires: systemd systemd-devel @@ -294,6 +295,12 @@ exit 0 %{_mandir}/man3/omapi.3.gz %changelog +* Mon Feb 7 2022 renmingshuai - 4.4.2-10 +- Type:bugfix +- ID:NA +- SUG:restart +- DESC:fix coredump when client active is NULL + * Wed Jan 12 2022 renmingshuai - 4.4.2-9 - Type:bugfix - ID:NA diff --git a/fix-coredump-when-client-active-is-NULL.patch b/fix-coredump-when-client-active-is-NULL.patch new file mode 100644 index 0000000..ff42768 --- /dev/null +++ b/fix-coredump-when-client-active-is-NULL.patch @@ -0,0 +1,67 @@ +From 098d7f8e2e2b468e6a615084fb4330fed49bb54a Mon Sep 17 00:00:00 2001 +From: hanzhijun +Date: Mon, 24 Aug 2020 15:39:53 +0800 +Subject: [PATCH] fix coredump when client -> active is NULL + +--- + client/dhclient.c | 37 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/client/dhclient.c b/client/dhclient.c +index 2a17bfd..7581670 100644 +--- a/client/dhclient.c ++++ b/client/dhclient.c +@@ -2059,6 +2059,24 @@ void state_bound (cpp) + struct data_string ds; + + ASSERT_STATE(state, S_BOUND); ++ if (!client -> active) ++ { ++ struct timeval tv; ++ ++ log_error ("No active lease in bound."); ++ script_init(client, "FAIL", (struct string_list *)0); ++ if (client -> alias) ++ script_write_params(client, "alias_", client -> alias); ++ script_go(client); ++ client -> state = S_INIT; ++ tv.tv_sec = cur_tv.tv_sec + ((client->config->retry_interval + 1) / 2 + ++ (random() % client->config->retry_interval)); ++ tv.tv_usec = ((tv.tv_sec - cur_tv.tv_sec) > 1) ? ++ random() % 1000000 : cur_tv.tv_usec; ++ add_timeout(&tv, state_init, client, 0, 0); ++ detach (); ++ return; ++ } + + /* T1 has expired. */ + make_request (client, client -> active); +@@ -3173,6 +3191,25 @@ void send_request (cpp) + return; + } + ++ if (!client -> active && client -> state != S_REQUESTING) ++ { ++ struct timeval tv; ++ ++ log_error ("No active lease in request."); ++ script_init(client, "FAIL", (struct string_list *)0); ++ if (client -> alias) ++ script_write_params(client, "alias_", client -> alias); ++ script_go(client); ++ client -> state = S_INIT; ++ tv.tv_sec = cur_tv.tv_sec + ((client->config->retry_interval + 1) / 2 + ++ (random() % client->config->retry_interval)); ++ tv.tv_usec = ((tv.tv_sec - cur_tv.tv_sec) > 1) ? ++ random() % 1000000 : cur_tv.tv_usec; ++ add_timeout(&tv, state_init, client, 0, 0); ++ detach (); ++ return; ++ } ++ + /* If we're in the reboot state, make sure the media is set up + correctly. */ + if (client -> state == S_REBOOTING && +-- +2.27.0 + -- Gitee