BUG/MINOR: session: Add some forgotten tests on session's listener
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 10:26:15 +0000 (11:26 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 10:26:16 +0000 (11:26 +0100)
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.

src/http_ana.c

index a1dd807..1e144c7 100644 (file)
@@ -151,7 +151,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->listener, 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;
@@ -177,7 +177,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->listener, 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;
@@ -204,7 +204,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->listener, 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;
@@ -220,7 +220,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