Skip to content

Commit 39f801e

Browse files
committed
Bug#36292125 use-after-free in async-recv
ASAN reported a use-after-free when a Channel is std::move()d in async_recv(). 1. the move() .cancel()s all async-operations 2. the async operation MUST not touch anything if it is canceled. async_recv() calls view_sync_raw() on a destructed part of the moved-channel. Change ====== - only sync the view on success of the async operation. Change-Id: I82d9ea666c4db5a8962d4f63ac1cbc3884974d4e
1 parent e1016b2 commit 39f801e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

router/src/routing/src/basic_protocol_splicer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ class TlsSwitchableConnection {
364364
conn_->async_recv(channel_->recv_buffer(),
365365
[this, func = std::forward<Func>(func)](
366366
std::error_code ec, size_t transferred) {
367-
channel_->view_sync_raw();
367+
if (ec == std::error_code()) {
368+
channel_->view_sync_raw();
369+
}
368370

369371
func(ec, transferred);
370372
});

0 commit comments

Comments
 (0)