From 25af0d411fb8af2bef3e763c2a7e7ea9c561194b Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 12 Mar 2021 11:26:15 +0100 Subject: [PATCH] BUG/MINOR: session: Add some forgotten tests on session's listener During backport of commit 36119de18 ("BUG/MEDIUM: session: NULL dereference possible when accessing the listener"), I missed some tests on the session's listener because of the context changes. It is specific to the 2.3, thus there is no upstream commit ID. It must backported with the above commit as far as 1.8. (cherry picked from commit e3f9f2bd9df54a3c05d9e3b21fadc39d771853a9) Signed-off-by: Christopher Faulet (cherry picked from commit a648a4fc9d485c063ddfd544a056f06c1681052a) Signed-off-by: Christopher Faulet --- src/http_ana.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/http_ana.c b/src/http_ana.c index 9122c57..85951dc 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -149,7 +149,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); _HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); - if (sess->listener->counters) + if (sess->listener && sess->listener->counters) _HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); txn->status = 400; @@ -175,7 +175,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); _HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); - if (sess->listener->counters) + if (sess->listener && sess->listener->counters) _HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); txn->status = 408; @@ -202,7 +202,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); _HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); - if (sess->listener->counters) + if (sess->listener && sess->listener->counters) _HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); txn->status = 400; @@ -218,7 +218,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) req->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */ - if (sess->listener->options & LI_O_NOQUICKACK && htx_is_not_empty(htx) && + if (sess->listener && (sess->listener->options & LI_O_NOQUICKACK) && htx_is_not_empty(htx) && objt_conn(sess->origin) && conn_ctrl_ready(__objt_conn(sess->origin))) { /* We need more data, we have to re-enable quick-ack in case we * previously disabled it, otherwise we might cause the client -- 1.7.10.4