From 3331222973762ca07b47d92c42adcaafd863aae4 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Thu, 27 Feb 2020 11:15:23 +0100 Subject: [PATCH] Don't dereference potentially uninitialized smart pointers Fix #18 --- src/callouts.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/callouts.cc b/src/callouts.cc index e872714..564a0f9 100644 --- a/src/callouts.cc +++ b/src/callouts.cc @@ -152,7 +152,11 @@ void extract_lease4(std::vector& env, const Lease4Ptr lease) env.push_back("KEA_LEASE4_STATE=" + lease->basicStatesToText(lease->state_)); extract_bool(env, "KEA_LEASE4_IS_EXPIRED", lease->expired()); env.push_back("KEA_LEASE4_ADDRESS=" + lease->addr_.toText()); - env.push_back("KEA_LEASE4_HWADDR=" + lease->hwaddr_->toText(false)); + if (lease->hwaddr_) { + env.push_back("KEA_LEASE4_HWADDR=" + lease->hwaddr_->toText(false)); + } else { + env.push_back("KEA_LEASE4_HWADDR="); + } env.push_back("KEA_LEASE4_HOSTNAME=" + lease->hostname_); env.push_back("KEA_LEASE4_CLIENT_LAST_TRANSMISSION=" + std::to_string(lease->cltt_)); env.push_back("KEA_LEASE4_VALID_LIFETIME=" + std::to_string(lease->valid_lft_)); @@ -169,7 +173,11 @@ void extract_lease6(std::vector& env, const Lease6Ptr lease) env.push_back("KEA_LEASE6_DELEGATED_PREFIX=" + lease->addr_.toText() + "/" + std::to_string(lease->prefixlen_)); env.push_back("KEA_LEASE6_DELEGATED_PREFIXLEN=" + std::to_string(lease->prefixlen_)); } - env.push_back("KEA_LEASE6_HWADDR=" + lease->hwaddr_->toText(false)); + if (lease->hwaddr_) { + env.push_back("KEA_LEASE6_HWADDR=" + lease->hwaddr_->toText(false)); + } else { + env.push_back("KEA_LEASE6_HWADDR="); + } env.push_back("KEA_LEASE6_HOSTNAME=" + lease->hostname_); env.push_back("KEA_LEASE6_CLIENT_DUID=" + lease->duid_->toText()); env.push_back("KEA_LEASE6_CLIENT_LAST_TRANSMISSION=" + std::to_string(lease->cltt_));