From: Tomek Mrugalski Date: Wed, 2 Aug 2017 11:40:57 +0000 (+0200) Subject: [5314] Fix for segfault, courtesy of Marcin X-Git-Tag: trac5124a_base~9^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bb418a512ab4a8c8b8cb97dbde8bee9682bc496;p=thirdparty%2Fkea.git [5314] Fix for segfault, courtesy of Marcin - applied the patch provided as ticket attachment --- diff --git a/src/lib/config/hooked_command_mgr.cc b/src/lib/config/hooked_command_mgr.cc index 9a8e091c6a..604e07c597 100644 --- a/src/lib/config/hooked_command_mgr.cc +++ b/src/lib/config/hooked_command_mgr.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,7 @@ namespace isc { namespace config { HookedCommandMgr::HookedCommandMgr() - : BaseCommandMgr(), callout_handle_(HooksManager::createCalloutHandle()) { + : BaseCommandMgr() { } bool @@ -31,25 +32,25 @@ HookedCommandMgr::delegateCommandToHookLibrary(const std::string& cmd_name, ConstElementPtr hook_response; if (HooksManager::commandHandlersPresent(cmd_name)) { - callout_handle_ = HooksManager::createCalloutHandle(); + CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle(); // Set status to normal. - callout_handle_->setStatus(CalloutHandle::NEXT_STEP_CONTINUE); + callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE); // Delete previously set arguments. - callout_handle_->deleteAllArguments(); + callout_handle->deleteAllArguments(); ConstElementPtr command = original_cmd ? original_cmd : createCommand(cmd_name, params); // And pass it to the hook library. - callout_handle_->setArgument("command", command); - callout_handle_->setArgument("response", hook_response); + callout_handle->setArgument("command", command); + callout_handle->setArgument("response", hook_response); - HooksManager::callCommandHandlers(cmd_name, *callout_handle_); + HooksManager::callCommandHandlers(cmd_name, *callout_handle); // The callouts should set the response. - callout_handle_->getArgument("response", hook_response); + callout_handle->getArgument("response", hook_response); answer = boost::const_pointer_cast(hook_response); @@ -63,10 +64,6 @@ ConstElementPtr HookedCommandMgr::handleCommand(const std::string& cmd_name, const ConstElementPtr& params, const ConstElementPtr& original_cmd) { - if (!callout_handle_) { - isc_throw(Unexpected, "callout handle not configured for the Command " - "Manager: this is a programming error"); - } // The 'list-commands' is a special case. Hook libraries do not implement // this command. We determine what commands are supported by the hook diff --git a/src/lib/config/hooked_command_mgr.h b/src/lib/config/hooked_command_mgr.h index bfa2ada933..edd8e4e9ac 100644 --- a/src/lib/config/hooked_command_mgr.h +++ b/src/lib/config/hooked_command_mgr.h @@ -9,7 +9,6 @@ #include #include -#include namespace isc { namespace config { @@ -47,13 +46,6 @@ public: protected: - /// @brief Returns callout handle to the derived class. - /// - /// @return const pointer to the callout handle. - const isc::hooks::CalloutHandlePtr& getCalloutHandle() const { - return (callout_handle_); - } - /// @brief Handles the command within the hooks libraries. /// /// This method checks if the hooks libraries are installed which implement @@ -91,8 +83,6 @@ protected: const isc::data::ConstElementPtr& params, const isc::data::ConstElementPtr& original_cmd); - /// @brief Pointer to a callout handle used by this class. - isc::hooks::CalloutHandlePtr callout_handle_; }; } // end of namespace isc::config