From c41f93c5cd9322b0f6e9a7e6a8f43c16e97f0877 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 4 May 2022 09:52:48 +0200 Subject: [PATCH] BUG/MEDIUM: conn-stream: Only keep app layer flags of the endpoint on reset The commit a6c4a4834 ("BUG/MEDIUM: conn-stream: Don't erase endpoint flags on reset") was too laxy on reset. Only app layer flags must be preserved. On reset, the endpoint is detached. Thus all flags set by the endpoint itself or concerning its type must be removed. Without this fix, we can experienced crashes when a stream is released while a server connection attempt failed. Indeed, in this case, endpoint of the backend conn-stream is reset. But the endpoint type is still set. Thus when the stream is released, the endpoint is detached again. This patch is 2.6-specific. No backport needed. This commit depends on the previous one ("MINOR: conn-stream: Add mask from flags set by endpoint or app layer"). --- src/conn_stream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conn_stream.c b/src/conn_stream.c index 78d30354e..b5147905b 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -394,6 +394,7 @@ static void cs_detach_endp(struct conn_stream **csp) /* the cs is the only one one the endpoint */ cs->endp->target = NULL; cs->endp->ctx = NULL; + cs->endp->flags &= CS_EP_APP_MASK; cs->endp->flags |= CS_EP_DETACHED; } @@ -471,7 +472,7 @@ int cs_reset_endp(struct conn_stream *cs) cs->endp->flags |= CS_EP_ERROR; return -1; } - new_endp->flags = cs->endp->flags; + new_endp->flags = (cs->endp->flags & CS_EP_APP_MASK); /* The app is still attached, the cs will not be released */ cs_detach_endp(&cs);