From 5869cb669e31f728440db63ff73db163ae38ae3a Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 31 May 2022 15:21:27 +0200 Subject: [PATCH] BUG/MINOR: qpack: do not consider empty enc/dec stream as error When parsing QPACK encoder/decoder streams, h3_decode_qcs() displays an error trace if they are empty. Change the return code used in QPACK code to avoid this trace. To uniformize with MUX/H3 code, 0 is now used to indicate success. Beyond this spurious error trace, this bug has no impact. --- src/h3.c | 4 ++-- src/qpack-dec.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/h3.c b/src/h3.c index 831dc19de..1b8e37831 100644 --- a/src/h3.c +++ b/src/h3.c @@ -238,11 +238,11 @@ static int h3_parse_uni_stream_no_h3(struct qcs *qcs, struct ncbuf *rxbuf) switch (h3s->type) { case H3S_T_QPACK_DEC: - if (!qpack_decode_dec(qcs, NULL)) + if (qpack_decode_dec(qcs, NULL)) return 1; break; case H3S_T_QPACK_ENC: - if (!qpack_decode_enc(qcs, NULL)) + if (qpack_decode_enc(qcs, NULL)) return 1; break; case H3S_T_UNKNOWN: diff --git a/src/qpack-dec.c b/src/qpack-dec.c index c5e42a0f5..3ca2eda65 100644 --- a/src/qpack-dec.c +++ b/src/qpack-dec.c @@ -93,7 +93,10 @@ static uint64_t qpack_get_varint(const unsigned char **buf, uint64_t *len_in, in return 0; } -/* Decode an encoder stream */ +/* Decode an encoder stream. + * + * Returns 0 on success else non-zero. + */ int qpack_decode_enc(struct qcs *qcs, void *ctx) { size_t len; @@ -123,10 +126,13 @@ int qpack_decode_enc(struct qcs *qcs, void *ctx) /* Set dynamic table capacity */ } - return 1; + return 0; } -/* Decode an decoder stream */ +/* Decode an decoder stream. + * + * Returns 0 on success else non-zero. + */ int qpack_decode_dec(struct qcs *qcs, void *ctx) { size_t len; @@ -153,7 +159,7 @@ int qpack_decode_dec(struct qcs *qcs, void *ctx) /* Stream cancellation */ } - return 1; + return 0; } /* Decode a field section prefix made of and two varints.