nghttpx: Fix heap-after-free crash in https upstream
Add Upstream::on_handler_delete() hook to safely write log for HttpsUpstream.
This commit is contained in:
parent
958cd0de64
commit
27609327ee
|
@ -221,6 +221,10 @@ ClientHandler::~ClientHandler()
|
||||||
CLOG(INFO, this) << "Deleting";
|
CLOG(INFO, this) << "Deleting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(upstream_) {
|
||||||
|
upstream_->on_handler_delete();
|
||||||
|
}
|
||||||
|
|
||||||
--worker_stat_->num_connections;
|
--worker_stat_->num_connections;
|
||||||
|
|
||||||
// TODO If backend is http/2, and it is in CONNECTED state, signal
|
// TODO If backend is http/2, and it is in CONNECTED state, signal
|
||||||
|
|
|
@ -1466,4 +1466,7 @@ void Http2Upstream::reset_timeouts()
|
||||||
&get_config()->upstream_write_timeout);
|
&get_config()->upstream_write_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Http2Upstream::on_handler_delete()
|
||||||
|
{}
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
|
@ -74,6 +74,8 @@ public:
|
||||||
const uint8_t *data, size_t len, bool flush);
|
const uint8_t *data, size_t len, bool flush);
|
||||||
virtual int on_downstream_body_complete(Downstream *downstream);
|
virtual int on_downstream_body_complete(Downstream *downstream);
|
||||||
|
|
||||||
|
virtual void on_handler_delete();
|
||||||
|
|
||||||
virtual void reset_timeouts();
|
virtual void reset_timeouts();
|
||||||
|
|
||||||
bool get_flow_control() const;
|
bool get_flow_control() const;
|
||||||
|
|
|
@ -57,12 +57,7 @@ HttpsUpstream::HttpsUpstream(ClientHandler *handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpsUpstream::~HttpsUpstream()
|
HttpsUpstream::~HttpsUpstream()
|
||||||
{
|
{}
|
||||||
if(downstream_ &&
|
|
||||||
downstream_->get_response_state() == Downstream::MSG_COMPLETE) {
|
|
||||||
handler_->write_accesslog(downstream_.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpsUpstream::reset_current_header_length()
|
void HttpsUpstream::reset_current_header_length()
|
||||||
{
|
{
|
||||||
|
@ -977,4 +972,12 @@ void HttpsUpstream::reset_timeouts()
|
||||||
&get_config()->upstream_write_timeout);
|
&get_config()->upstream_write_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpsUpstream::on_handler_delete()
|
||||||
|
{
|
||||||
|
if(downstream_ &&
|
||||||
|
downstream_->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||||
|
handler_->write_accesslog(downstream_.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
const uint8_t *data, size_t len, bool flush);
|
const uint8_t *data, size_t len, bool flush);
|
||||||
virtual int on_downstream_body_complete(Downstream *downstream);
|
virtual int on_downstream_body_complete(Downstream *downstream);
|
||||||
|
|
||||||
|
virtual void on_handler_delete();
|
||||||
|
|
||||||
virtual void reset_timeouts();
|
virtual void reset_timeouts();
|
||||||
|
|
||||||
void reset_current_header_length();
|
void reset_current_header_length();
|
||||||
|
|
|
@ -1154,4 +1154,7 @@ void SpdyUpstream::reset_timeouts()
|
||||||
&get_config()->upstream_write_timeout);
|
&get_config()->upstream_write_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpdyUpstream::on_handler_delete()
|
||||||
|
{}
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
const uint8_t *data, size_t len, bool flush);
|
const uint8_t *data, size_t len, bool flush);
|
||||||
virtual int on_downstream_body_complete(Downstream *downstream);
|
virtual int on_downstream_body_complete(Downstream *downstream);
|
||||||
|
|
||||||
|
virtual void on_handler_delete();
|
||||||
|
|
||||||
virtual void reset_timeouts();
|
virtual void reset_timeouts();
|
||||||
|
|
||||||
bool get_flow_control() const;
|
bool get_flow_control() const;
|
||||||
|
|
|
@ -56,6 +56,8 @@ public:
|
||||||
bool flush) = 0;
|
bool flush) = 0;
|
||||||
virtual int on_downstream_body_complete(Downstream *downstream) = 0;
|
virtual int on_downstream_body_complete(Downstream *downstream) = 0;
|
||||||
|
|
||||||
|
virtual void on_handler_delete() = 0;
|
||||||
|
|
||||||
virtual void pause_read(IOCtrlReason reason) = 0;
|
virtual void pause_read(IOCtrlReason reason) = 0;
|
||||||
virtual int resume_read(IOCtrlReason reason, Downstream *downstream,
|
virtual int resume_read(IOCtrlReason reason, Downstream *downstream,
|
||||||
size_t consumed) = 0;
|
size_t consumed) = 0;
|
||||||
|
|
Loading…
Reference in New Issue