]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: fix possible invalid dereference on htx parsing
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 8 Dec 2021 14:51:04 +0000 (15:51 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 8 Dec 2021 14:52:59 +0000 (15:52 +0100)
The htx variable is only initialized if we have received a HTTP/3
HEADERS frame. Else it must not be dereferenced.

This should fix the compilation on CI with gcc.
  src/h3.c: In function ‘h3_decode_qcs’:
  src/h3.c:224:14: error: ‘htx’ may be used uninitialized in this function
  [-Werror=maybe-uninitialized]
    224 |   htx->flags |= HTX_FL_EOM

src/h3.c

index 970b95752d06b3178e93f4c2796c55018380e4bb..79d746001571085a754b6fba36e92c3a8272a50a 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -100,7 +100,7 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
 {
        struct buffer *rxbuf = &qcs->rx.buf;
        struct h3 *h3 = ctx;
-       struct htx *htx;
+       struct htx *htx = NULL;
        struct htx_sl *sl;
        struct conn_stream *cs;
        struct http_hdr list[global.tune.max_http_hdr];
@@ -220,8 +220,10 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                b_del(rxbuf, flen);
        }
 
-       if (fin && !b_data(rxbuf))
-               htx->flags |= HTX_FL_EOM;
+       if (htx) {
+               if (fin && !b_data(rxbuf))
+                       htx->flags |= HTX_FL_EOM;
+       }
 
        return 0;