From: Mike Stepanek (mstepane) Date: Thu, 10 Jan 2019 18:12:00 +0000 (-0500) Subject: Merge pull request #1479 in SNORT/snort3 from ~MASHASAN/snort3:socket_crash to master X-Git-Tag: 3.0.0-251~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4a27f75daf5af4b67e709f04e90b37c1e361498;p=thirdparty%2Fsnort3.git Merge pull request #1479 in SNORT/snort3 from ~MASHASAN/snort3:socket_crash to master Squashed commit of the following: commit ebcfc6b5298aeb1af5dac7570412fa95feeed1a0 Author: Masud Hasan Date: Tue Jan 8 10:16:36 2019 -0500 control: Avoid deleting objects on write failures so that they get deleted from main thread during read polling --- diff --git a/src/main/control.cc b/src/main/control.cc index dbc5a44c7..089fdbbe8 100644 --- a/src/main/control.cc +++ b/src/main/control.cc @@ -91,14 +91,11 @@ void ControlConn::unblock() ControlMgmt::delete_control(fd); } -bool ControlConn::send_queued_response() +void ControlConn::send_queued_response() { - if ( !request->send_queued_response() ) - { - ControlMgmt::delete_control(fd); - return false; - } - return true; +#ifdef SHELL + request->send_queued_response(); +#endif } // FIXIT-L would like to flush prompt w/o \n diff --git a/src/main/control.h b/src/main/control.h index f3dbc0abe..269009fa8 100644 --- a/src/main/control.h +++ b/src/main/control.h @@ -41,7 +41,7 @@ public: void block(); void unblock(); - bool send_queued_response(); + void send_queued_response(); bool is_blocked() const { return blocked; } void configure() const; diff --git a/src/main/control_mgmt.cc b/src/main/control_mgmt.cc index 32c6b82e2..0599a6a5e 100644 --- a/src/main/control_mgmt.cc +++ b/src/main/control_mgmt.cc @@ -288,13 +288,7 @@ void ACShellCmd::execute(Analyzer& analyzer) ControlConn* control = (control_fd >= 0)? (ControlMgmt::find_control(control_fd) ) : nullptr; if( control ) - { - if ( !control->send_queued_response() ) - { - control_fd = -1; - return; - } - } + control->send_queued_response(); ac->execute(analyzer); } diff --git a/src/main/request.cc b/src/main/request.cc index efed766da..4cfcb63cd 100644 --- a/src/main/request.cc +++ b/src/main/request.cc @@ -101,15 +101,12 @@ void Request::respond(const char* s, bool queue_response) } #ifdef SHELL -bool Request::send_queued_response() +void Request::send_queued_response() { - bool ret = true; if ( queued_response ) { - ret = write_response(queued_response); + write_response(queued_response); queued_response = nullptr; } - - return ret; } #endif diff --git a/src/main/request.h b/src/main/request.h index 61e048ba2..e470c55e3 100644 --- a/src/main/request.h +++ b/src/main/request.h @@ -34,7 +34,7 @@ public: bool write_response(const char* s) const; void respond(const char* s, bool queue_response = false); #ifdef SHELL - bool send_queued_response(); + void send_queued_response(); #endif private: