From 318adf43648143292a6e6b74d4600b4908172598 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 22 May 2020 12:09:16 +0200 Subject: [PATCH] CONTRIB: hpack: make use of the simplified standalone HPACK API As reported in oss-fuzz issue 22388, the contrib/hpack code doesn't build anymore for now. Thanks to previous patch we can now just define HPACK_STANDALONE in the few files which include hpack-tbl.h and we can declare a dummy pool to hold the DHT size. This is enough to make the code work again outside of the haproxy process. It was successfully tested using: $ echo 82 84 87 90 | ./decode --- contrib/hpack/decode.c | 8 +++++++- contrib/hpack/gen-enc.c | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/hpack/decode.c b/contrib/hpack/decode.c index 51ebbf3ea7..82f28c7f18 100644 --- a/contrib/hpack/decode.c +++ b/contrib/hpack/decode.c @@ -10,6 +10,9 @@ * gcc -I../../include -I../../ebtree -O0 -g -fno-strict-aliasing -fwrapv \ * -o decode decode.c */ + +#define HPACK_STANDALONE + #include #include #include @@ -153,6 +156,7 @@ int main(int argc, char **argv) { struct hpack_dht *dht; struct http_hdr list[MAX_HDR_NUM]; + struct pool_head pool; int outlen; int dht_size = 4096; int len, idx; @@ -164,7 +168,9 @@ int main(int argc, char **argv) argv++; argc--; } - dht = hpack_dht_alloc(dht_size); + pool.size = dht_size; + pool_head_hpack_tbl = &pool; + dht = hpack_dht_alloc(); if (!dht) { die(1, "cannot initialize dht\n"); return 1; diff --git a/contrib/hpack/gen-enc.c b/contrib/hpack/gen-enc.c index 3d6b64b505..44b643c93d 100644 --- a/contrib/hpack/gen-enc.c +++ b/contrib/hpack/gen-enc.c @@ -7,6 +7,8 @@ * Build like this : * gcc -I../../include -I../../ebtree -o gen-enc gen-enc.c */ +#define HPACK_STANDALONE + #include #include #include