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
diff --git a/contrib/hpack/decode.c b/contrib/hpack/decode.c
index 51ebbf3..82f28c7 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 <ctype.h>
#include <inttypes.h>
#include <stdio.h>
@@ -153,6 +156,7 @@
{
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 @@
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 3d6b64b..44b643c 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 <ctype.h>
#include <inttypes.h>
#include <stdio.h>