]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: quic: Possible leak when allocating an encryption level
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 3 Jul 2023 08:28:33 +0000 (10:28 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Mon, 3 Jul 2023 08:50:08 +0000 (10:50 +0200)
commit0e53cb07a5101969eddf26825a19411917139685
tree403f9ed9a5f70ef83a4ce1178cc1f7c33fa04c9a
parentfdc57c4021c20114665217106d6c05a260bdcbfc
BUG/MINOR: quic: Possible leak when allocating an encryption level

This bug was reported by GH #2200 (coverity issue) as follows:

*** CID 1516590:  Resource leaks  (RESOURCE_LEAK)
/src/quic_tls.c: 159 in quic_conn_enc_level_init()
153
154             LIST_APPEND(&qc->qel_list, &qel->list);
155             *el = qel;
156             ret = 1;
157      leave:
158             TRACE_LEAVE(QUIC_EV_CONN_CLOSE, qc);
>>>     CID 1516590:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "qel" going out of scope leaks the storage it points to.
159             return ret;
160     }
161
162     /* Uninitialize <qel> QUIC encryption level. Never fails. */
163     void quic_conn_enc_level_uninit(struct quic_conn *qc, struct quic_enc_level *qel)
164     {

This bug was introduced by this commit which has foolishly assumed the encryption
level memory would be released after quic_conn_enc_level_init() has failed. This
is no more possible because this object is dynamic and no more a static member
of the QUIC connection object.

Anyway, this patch modifies quic_conn_enc_level_init() to ensure this is
no more leak when quic_conn_enc_level_init() fails calling quic_conn_enc_level_uninit()
in case of memory allocation error.

quic_conn_enc_level_uninit() code was moved without modification only to be defined
before quic_conn_enc_level_init()

There is no need to backport this.
src/quic_tls.c