]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CONTRIB: hpack: make use of the simplified standalone HPACK API
authorWilly Tarreau <w@1wt.eu>
Fri, 22 May 2020 10:09:16 +0000 (12:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 22 May 2020 10:13:43 +0000 (12:13 +0200)
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
contrib/hpack/gen-enc.c

index 51ebbf3ea7881d1ed99fd63822f95da7cec5c89b..82f28c7f18f6e5b16b0cc44ab6d29868230477bd 100644 (file)
@@ -10,6 +10,9 @@
  *    gcc -I../../include -I../../ebtree -O0 -g -fno-strict-aliasing -fwrapv \
  *        -o decode decode.c
  */
+
+#define HPACK_STANDALONE
+
 #include <ctype.h>
 #include <inttypes.h>
 #include <stdio.h>
@@ -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;
index 3d6b64b50516b7b9d588f97712c6bf7ff3e916b9..44b643c93de3367cc54d387c1801400538248660 100644 (file)
@@ -7,6 +7,8 @@
  * Build like this :
  *    gcc -I../../include -I../../ebtree -o gen-enc gen-enc.c
  */
+#define HPACK_STANDALONE
+
 #include <ctype.h>
 #include <inttypes.h>
 #include <stdio.h>