Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
ca88d434
Commit
ca88d434
authored
Sep 08, 2023
by
Walid Boudebouda
Committed by
Dridi Boukelmoune
Oct 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hpack: Turn header validation state into an enum
Signed-off-by:
Dridi Boukelmoune
<
dridi.boukelmoune@gmail.com
>
parent
42b4d320
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
cache_http2_hpack.c
bin/varnishd/http2/cache_http2_hpack.c
+15
-9
No files found.
bin/varnishd/http2/cache_http2_hpack.c
View file @
ca88d434
...
...
@@ -44,6 +44,12 @@ static h2_error
h2h_checkhdr
(
const
struct
http
*
hp
,
const
char
*
b
,
size_t
namelen
,
size_t
len
)
{
const
char
*
p
;
enum
{
FLD_NAME_FIRST
,
FLD_NAME
,
FLD_VALUE_FIRST
,
FLD_VALUE
}
state
;
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
AN
(
b
);
...
...
@@ -60,15 +66,15 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
// VSLb(hp->vsl, SLT_Debug, "CHDR [%.*s] [%.*s]",
// (int)namelen, b, (int)(len - namelen), b + namelen);
int
state
=
0
;
state
=
FLD_NAME_FIRST
;
for
(
p
=
b
;
p
<
b
+
namelen
-
2
;
p
++
)
{
switch
(
state
)
{
case
0
:
/* First char of field */
state
=
1
;
case
FLD_NAME_FIRST
:
state
=
FLD_NAME
;
if
(
*
p
==
':'
)
break
;
/* FALL_THROUGH */
case
1
:
/* field name */
case
FLD_NAME
:
if
(
*
p
<=
0x20
||
*
p
>=
0x7f
)
{
VSLb
(
hp
->
vsl
,
SLT_BogoHeader
,
"Illegal field header name (control): %.*s"
,
...
...
@@ -93,19 +99,19 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
}
}
state
=
2
;
state
=
FLD_VALUE_FIRST
;
for
(
p
=
b
+
namelen
;
p
<
b
+
len
;
p
++
)
{
switch
(
state
)
{
case
2
:
/* First char of field */
case
FLD_VALUE_FIRST
:
if
(
*
p
==
' '
||
*
p
==
0x09
)
{
VSLb
(
hp
->
vsl
,
SLT_BogoHeader
,
"Illegal field value start %.*s"
,
(
int
)(
len
>
20
?
20
:
len
),
b
);
return
(
H2SE_PROTOCOL_ERROR
);
}
state
=
3
;
state
=
FLD_VALUE
;
/* FALL_THROUGH */
case
3
:
/* field value character */
case
FLD_VALUE
:
if
(
*
p
!=
0x09
&&
(
*
p
<
0x20
||
*
p
==
0x7f
))
{
VSLb
(
hp
->
vsl
,
SLT_BogoHeader
,
"Illegal field value (control) %.*s"
,
...
...
@@ -117,7 +123,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
WRONG
(
"http2 field value validation state"
);
}
}
if
(
state
==
3
&&
b
[
len
-
1
]
<=
0x20
)
{
if
(
state
==
FLD_VALUE
&&
b
[
len
-
1
]
<=
0x20
)
{
VSLb
(
hp
->
vsl
,
SLT_BogoHeader
,
"Illegal field value (end) %.*s"
,
(
int
)(
len
>
20
?
20
:
len
),
b
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment