Mailing List Archive

[master] 97e83ddb3 http2_hpack: New custom h2 error for http_req_size
commit 97e83ddb30903a4ff8843d2f44bcec075f96ff71
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Mar 28 16:02:53 2024 +0100

http2_hpack: New custom h2 error for http_req_size

diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c
index b47dba507..92858543e 100644
--- a/bin/varnishd/http2/cache_http2_hpack.c
+++ b/bin/varnishd/http2/cache_http2_hpack.c
@@ -343,7 +343,8 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
/* Only H2E_ENHANCE_YOUR_CALM indicates that we should continue
processing. Other errors should have been returned and handled
by the caller. */
- assert(d->error == 0 || d->error == H2SE_ENHANCE_YOUR_CALM);
+ if (d->error != NULL)
+ assert(H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM));

while (1) {
AN(d->out);
@@ -362,7 +363,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break;
}

- if (d->error == H2SE_ENHANCE_YOUR_CALM) {
+ if (H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM)) {
d->out_u = 0;
assert(d->out_u < d->out_l);
continue;
@@ -374,7 +375,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
case VHD_NAME:
assert(d->namelen == 0);
if (d->out_l - d->out_u < 2) {
- d->error = H2SE_ENHANCE_YOUR_CALM;
+ d->error = H2SE_REQ_SIZE;
break;
}
d->out[d->out_u++] = ':';
@@ -387,7 +388,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
case VHD_VALUE:
assert(d->namelen > 0);
if (d->out_l - d->out_u < 1) {
- d->error = H2SE_ENHANCE_YOUR_CALM;
+ d->error = H2SE_REQ_SIZE;
break;
}
d->error = h2h_addhdr(hp, d);
@@ -401,7 +402,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break;

case VHD_BUF:
- d->error = H2SE_ENHANCE_YOUR_CALM;
+ d->error = H2SE_REQ_SIZE;
break;

default:
@@ -409,7 +410,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break;
}

- if (d->error == H2SE_ENHANCE_YOUR_CALM) {
+ if (H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM)) {
d->out = d->reset;
d->out_l = e - d->out;
d->out_u = 0;
@@ -418,7 +419,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break;
}

- if (d->error == H2SE_ENHANCE_YOUR_CALM)
+ if (H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM))
return (0); /* Stream error, delay reporting until
h2h_decode_fini so that we can process the
complete header block */
diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h
index f4dc5ca2c..adfbbde42 100644
--- a/include/tbl/h2_error.h
+++ b/include/tbl/h2_error.h
@@ -197,6 +197,15 @@ H2_ERROR(
/* reason */ SC_BANKRUPT,
/* descr */ "http/2 bankrupt connection"
)
+
+H2_ERROR(
+ /* name */ REQ_SIZE,
+ /* val */ 11, /* ENHANCE_YOUR_CALM */
+ /* types */ 2,
+ /* goaway */ 0,
+ /* reason */ SC_NULL,
+ /* descr */ "HTTP/2 header list exceeded http_req_size"
+)
# undef H2_CUSTOM_ERRORS
#endif

_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit