Skip to content

Commit 8efd30d

Browse files
authored
[tcp_proxy] Add nullptr checks to watermark asserts (#40034)
<!-- !!!ATTENTION!!! If you are fixing *any* crash or *any* potential security issue, *do not* open a pull request in this repo. Please report the issue via emailing [email protected] where the issue will be triaged appropriately. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) --> Commit Message: Add nullptr checks into watermark asserts in tcp proxy to avoid potential segfaults. Additional Description: Risk Level: Low Testing: Docs Changes: Release Notes: Platform Specific Features: --------- Signed-off-by: Kateryna Nezdolii <[email protected]>
1 parent 4c1e53f commit 8efd30d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/common/tcp_proxy/tcp_proxy.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ void Filter::UpstreamCallbacks::onEvent(Network::ConnectionEvent event) {
436436
}
437437

438438
void Filter::UpstreamCallbacks::onAboveWriteBufferHighWatermark() {
439+
// In case when upstream connection is draining `parent_` will be set to nullptr.
439440
// TCP Tunneling may call on high/low watermark multiple times.
440-
ASSERT(parent_->config_->tunnelingConfigHelper() || !on_high_watermark_called_);
441+
ASSERT(parent_ == nullptr || parent_->config_->tunnelingConfigHelper() ||
442+
!on_high_watermark_called_);
441443
on_high_watermark_called_ = true;
442444

443445
if (parent_ != nullptr) {
@@ -447,8 +449,10 @@ void Filter::UpstreamCallbacks::onAboveWriteBufferHighWatermark() {
447449
}
448450

449451
void Filter::UpstreamCallbacks::onBelowWriteBufferLowWatermark() {
452+
// In case when upstream connection is draining `parent_` will be set to nullptr.
450453
// TCP Tunneling may call on high/low watermark multiple times.
451-
ASSERT(parent_->config_->tunnelingConfigHelper() || on_high_watermark_called_);
454+
ASSERT(parent_ == nullptr || parent_->config_->tunnelingConfigHelper() ||
455+
on_high_watermark_called_);
452456
on_high_watermark_called_ = false;
453457

454458
if (parent_ != nullptr) {

0 commit comments

Comments
 (0)