summaryrefslogtreecommitdiffstats
path: root/src/qpack-dec.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
commitcff6d757e3ba609c08ef2aaa00f07e53551e5bf6 (patch)
tree08c4fc3255483ad397d712edb4214ded49149fd9 /src/qpack-dec.c
parentAdding upstream version 2.9.7. (diff)
downloadhaproxy-cff6d757e3ba609c08ef2aaa00f07e53551e5bf6.tar.xz
haproxy-cff6d757e3ba609c08ef2aaa00f07e53551e5bf6.zip
Adding upstream version 3.0.0.upstream/3.0.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/qpack-dec.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/qpack-dec.c b/src/qpack-dec.c
index 7a8726f..5798b08 100644
--- a/src/qpack-dec.c
+++ b/src/qpack-dec.c
@@ -111,7 +111,7 @@ int qpack_decode_enc(struct buffer *buf, int fin, void *ctx)
* connection error of type H3_CLOSED_CRITICAL_STREAM.
*/
if (fin) {
- qcc_set_error(qcs->qcc, H3_CLOSED_CRITICAL_STREAM, 1);
+ qcc_set_error(qcs->qcc, H3_ERR_CLOSED_CRITICAL_STREAM, 1);
return -1;
}
@@ -144,7 +144,7 @@ int qpack_decode_enc(struct buffer *buf, int fin, void *ctx)
* QPACK_ENCODER_STREAM_ERROR.
*/
if (capacity) {
- qcc_set_error(qcs->qcc, QPACK_ENCODER_STREAM_ERROR, 1);
+ qcc_set_error(qcs->qcc, QPACK_ERR_ENCODER_STREAM_ERROR, 1);
return -1;
}
@@ -171,7 +171,7 @@ int qpack_decode_dec(struct buffer *buf, int fin, void *ctx)
* connection error of type H3_CLOSED_CRITICAL_STREAM.
*/
if (fin) {
- qcc_set_error(qcs->qcc, H3_CLOSED_CRITICAL_STREAM, 1);
+ qcc_set_error(qcs->qcc, H3_ERR_CLOSED_CRITICAL_STREAM, 1);
return -1;
}
@@ -196,7 +196,7 @@ int qpack_decode_dec(struct buffer *buf, int fin, void *ctx)
*/
/* For the moment haproxy does not emit dynamic table insertion. */
- qcc_set_error(qcs->qcc, QPACK_DECODER_STREAM_ERROR, 1);
+ qcc_set_error(qcs->qcc, QPACK_ERR_DECODER_STREAM_ERROR, 1);
return -1;
}
else if (inst & QPACK_DEC_INST_SACK) {
@@ -218,12 +218,12 @@ static int qpack_decode_fs_pfx(uint64_t *enc_ric, uint64_t *db, int *sign_bit,
{
*enc_ric = qpack_get_varint(raw, len, 8);
if (*len == (uint64_t)-1)
- return -QPACK_ERR_RIC;
+ return -QPACK_RET_RIC;
*sign_bit = **raw & 0x8;
*db = qpack_get_varint(raw, len, 7);
if (*len == (uint64_t)-1)
- return -QPACK_ERR_DB;
+ return -QPACK_RET_DB;
return 0;
}
@@ -234,7 +234,7 @@ static int qpack_decode_fs_pfx(uint64_t *enc_ric, uint64_t *db, int *sign_bit,
* the end of the list with empty strings as name/value.
*
* Returns the number of headers inserted into list excluding the end marker.
- * In case of error, a negative code QPACK_ERR_* is returned.
+ * In case of error, a negative code QPACK_RET_* is returned.
*/
int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
struct http_hdr *list, int list_size)
@@ -262,7 +262,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
while (len) {
if (hdr_idx >= list_size) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TOO_LARGE;
+ ret = -QPACK_RET_TOO_LARGE;
goto out;
}
@@ -283,7 +283,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
index = qpack_get_varint(&raw, &len, 3);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -292,7 +292,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
length = qpack_get_varint(&raw, &len, 7);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -300,7 +300,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
if (len < length) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -316,7 +316,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
* Count (Section 4.5.1), it MUST treat this as a connection error of
* type QPACK_DECOMPRESSION_FAILED.
*/
- return -QPACK_DECOMPRESSION_FAILED;
+ return -QPACK_RET_DECOMP;
}
else if (efl_type == QPACK_IFL_WPBI) {
/* Indexed field line with post-base index
@@ -329,7 +329,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
index = qpack_get_varint(&raw, &len, 4);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -344,7 +344,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
* Count (Section 4.5.1), it MUST treat this as a connection error of
* type QPACK_DECOMPRESSION_FAILED.
*/
- return -QPACK_DECOMPRESSION_FAILED;
+ return -QPACK_RET_DECOMP;
}
else if (efl_type & QPACK_IFL_BIT) {
/* Indexed field line */
@@ -356,7 +356,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
index = qpack_get_varint(&raw, &len, 6);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -375,7 +375,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
*
* TODO adjust this when dynamic table support is implemented.
*/
- return -QPACK_DECOMPRESSION_FAILED;
+ return -QPACK_RET_DECOMP;
}
qpack_debug_printf(stderr, " t=%d index=%llu", !!static_tbl, (unsigned long long)index);
@@ -391,7 +391,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
index = qpack_get_varint(&raw, &len, 4);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -409,7 +409,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
*
* TODO adjust this when dynamic table support is implemented.
*/
- return -QPACK_DECOMPRESSION_FAILED;
+ return -QPACK_RET_DECOMP;
}
qpack_debug_printf(stderr, " n=%d t=%d index=%llu", !!n, !!static_tbl, (unsigned long long)index);
@@ -417,7 +417,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
length = qpack_get_varint(&raw, &len, 7);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -429,13 +429,13 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
trash = chunk_newstr(tmp);
if (!trash) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_DECOMPRESSION_FAILED;
+ ret = -QPACK_RET_TOO_LARGE;
goto out;
}
nlen = huff_dec(raw, length, trash, tmp->size - tmp->data);
if (nlen == (uint32_t)-1) {
qpack_debug_printf(stderr, " can't decode huffman.\n");
- ret = -QPACK_ERR_HUFFMAN;
+ ret = -QPACK_RET_HUFFMAN;
goto out;
}
@@ -450,7 +450,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
if (len < length) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -468,7 +468,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
name_len = qpack_get_varint(&raw, &len, 3);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -477,7 +477,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
if (len < name_len) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -488,13 +488,13 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
trash = chunk_newstr(tmp);
if (!trash) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_DECOMPRESSION_FAILED;
+ ret = -QPACK_RET_TOO_LARGE;
goto out;
}
nlen = huff_dec(raw, name_len, trash, tmp->size - tmp->data);
if (nlen == (uint32_t)-1) {
qpack_debug_printf(stderr, " can't decode huffman.\n");
- ret = -QPACK_ERR_HUFFMAN;
+ ret = -QPACK_RET_HUFFMAN;
goto out;
}
@@ -514,7 +514,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
value_len = qpack_get_varint(&raw, &len, 7);
if (len == (uint64_t)-1) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -522,7 +522,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
if (len < value_len) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TRUNCATED;
+ ret = -QPACK_RET_TRUNCATED;
goto out;
}
@@ -533,13 +533,13 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
trash = chunk_newstr(tmp);
if (!trash) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_DECOMPRESSION_FAILED;
+ ret = -QPACK_RET_TOO_LARGE;
goto out;
}
nlen = huff_dec(raw, value_len, trash, tmp->size - tmp->data);
if (nlen == (uint32_t)-1) {
qpack_debug_printf(stderr, " can't decode huffman.\n");
- ret = -QPACK_ERR_HUFFMAN;
+ ret = -QPACK_RET_HUFFMAN;
goto out;
}
@@ -561,7 +561,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
*/
if (!name.len) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_DECOMPRESSION_FAILED;
+ ret = -QPACK_RET_DECOMP;
goto out;
}
@@ -574,7 +574,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
if (hdr_idx >= list_size) {
qpack_debug_printf(stderr, "##ERR@%d\n", __LINE__);
- ret = -QPACK_ERR_TOO_LARGE;
+ ret = -QPACK_RET_TOO_LARGE;
goto out;
}
@@ -586,3 +586,11 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
qpack_debug_printf(stderr, "-- done: ret=%d\n", ret);
return ret;
}
+
+/* Convert return value from qpack_decode_fs() to a standard error code usable
+ * in CONNECTION_CLOSE or -1 for an internal error.
+ */
+int qpack_err_decode(const int value)
+{
+ return (value == -QPACK_RET_DECOMP) ? QPACK_ERR_DECOMPRESSION_FAILED : -1;
+}