Commit 97e83ddb authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

http2_hpack: New custom h2 error for http_req_size

parent 803140a9
...@@ -343,7 +343,8 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -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 /* Only H2E_ENHANCE_YOUR_CALM indicates that we should continue
processing. Other errors should have been returned and handled processing. Other errors should have been returned and handled
by the caller. */ 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) { while (1) {
AN(d->out); AN(d->out);
...@@ -362,7 +363,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -362,7 +363,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break; break;
} }
if (d->error == H2SE_ENHANCE_YOUR_CALM) { if (H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM)) {
d->out_u = 0; d->out_u = 0;
assert(d->out_u < d->out_l); assert(d->out_u < d->out_l);
continue; continue;
...@@ -374,7 +375,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -374,7 +375,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
case VHD_NAME: case VHD_NAME:
assert(d->namelen == 0); assert(d->namelen == 0);
if (d->out_l - d->out_u < 2) { if (d->out_l - d->out_u < 2) {
d->error = H2SE_ENHANCE_YOUR_CALM; d->error = H2SE_REQ_SIZE;
break; break;
} }
d->out[d->out_u++] = ':'; d->out[d->out_u++] = ':';
...@@ -387,7 +388,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -387,7 +388,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
case VHD_VALUE: case VHD_VALUE:
assert(d->namelen > 0); assert(d->namelen > 0);
if (d->out_l - d->out_u < 1) { if (d->out_l - d->out_u < 1) {
d->error = H2SE_ENHANCE_YOUR_CALM; d->error = H2SE_REQ_SIZE;
break; break;
} }
d->error = h2h_addhdr(hp, d); 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) ...@@ -401,7 +402,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break; break;
case VHD_BUF: case VHD_BUF:
d->error = H2SE_ENHANCE_YOUR_CALM; d->error = H2SE_REQ_SIZE;
break; break;
default: default:
...@@ -409,7 +410,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -409,7 +410,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break; break;
} }
if (d->error == H2SE_ENHANCE_YOUR_CALM) { if (H2_ERROR_MATCH(d->error, H2SE_ENHANCE_YOUR_CALM)) {
d->out = d->reset; d->out = d->reset;
d->out_l = e - d->out; d->out_l = e - d->out;
d->out_u = 0; d->out_u = 0;
...@@ -418,7 +419,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l) ...@@ -418,7 +419,7 @@ h2h_decode_bytes(struct h2_sess *h2, const uint8_t *in, size_t in_l)
break; 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 return (0); /* Stream error, delay reporting until
h2h_decode_fini so that we can process the h2h_decode_fini so that we can process the
complete header block */ complete header block */
......
...@@ -197,6 +197,15 @@ H2_ERROR( ...@@ -197,6 +197,15 @@ H2_ERROR(
/* reason */ SC_BANKRUPT, /* reason */ SC_BANKRUPT,
/* descr */ "http/2 bankrupt connection" /* 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 # undef H2_CUSTOM_ERRORS
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment