Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
f0ef6e98
Commit
f0ef6e98
authored
Aug 28, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor nghttp2_hd_inflate_hd
parent
400615ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
108 deletions
+33
-108
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+33
-108
No files found.
lib/nghttp2_hd.c
View file @
f0ef6e98
...
...
@@ -900,11 +900,10 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
goto
fail
;
}
}
}
else
if
(
c
==
0x60u
||
c
==
0x40u
)
{
/* Literal Header without Indexing - new name or Literal Header
with incremental indexing - new name */
}
else
if
(
c
==
0x40u
||
c
==
0x60u
||
c
==
0
)
{
/* Literal Header Repr - New Name */
nghttp2_nv
nv
;
ssize_t
namelen
,
valuelen
;
ssize_t
namelen
,
valuelen
,
subindex
;
if
(
++
in
==
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
...
...
@@ -920,6 +919,13 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
}
nv
.
name
=
in
;
in
+=
namelen
;
if
(
c
==
0
)
{
in
=
decode_length
(
&
subindex
,
in
,
last
,
8
);
if
(
subindex
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
}
in
=
decode_length
(
&
valuelen
,
in
,
last
,
8
);
if
(
valuelen
<
0
||
in
+
valuelen
>
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
...
...
@@ -934,25 +940,26 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
rv
=
emit_newname_header
(
inflater
,
&
nva_out
,
&
nv
);
}
else
{
nghttp2_hd_entry
*
new_ent
;
new_ent
=
add_hd_table_incremental
(
inflater
,
&
nv
);
if
(
c
==
0
)
{
new_ent
=
add_hd_table_subst
(
inflater
,
&
nv
,
subindex
);
}
else
{
new_ent
=
add_hd_table_incremental
(
inflater
,
&
nv
);
}
if
(
new_ent
)
{
rv
=
emit_indexed_header
(
inflater
,
&
nva_out
,
new_ent
);
}
else
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
}
if
(
rv
<
0
)
{
if
(
rv
!=
0
)
{
goto
fail
;
}
}
else
if
((
c
&
0x60u
)
==
0x60u
||
(
c
&
0x40
)
==
0x40u
)
{
/* Literal Header without Indexing - indexed name or Literal
Header with incremental indexing - indexed name */
}
else
{
/* Literal Header Repr - Indexed Name */
nghttp2_hd_entry
*
ent
;
uint8_t
*
value
;
ssize_t
valuelen
;
ssize_t
index
;
in
=
decode_length
(
&
index
,
in
,
last
,
5
);
ssize_t
valuelen
,
index
,
subindex
;
in
=
decode_length
(
&
index
,
in
,
last
,
(
c
&
0x40u
)
?
5
:
6
);
if
(
index
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
...
...
@@ -963,6 +970,13 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
goto
fail
;
}
ent
=
inflater
->
hd_table
[
index
];
if
((
c
&
0x40u
)
==
0
)
{
in
=
decode_length
(
&
subindex
,
in
,
last
,
8
);
if
(
subindex
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
}
in
=
decode_length
(
&
valuelen
,
in
,
last
,
8
);
if
(
valuelen
<
0
||
in
+
valuelen
>
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
...
...
@@ -980,7 +994,11 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
nv
.
namelen
=
ent
->
nv
.
namelen
;
nv
.
value
=
value
;
nv
.
valuelen
=
valuelen
;
new_ent
=
add_hd_table_incremental
(
inflater
,
&
nv
);
if
((
c
&
0x40u
)
==
0
)
{
new_ent
=
add_hd_table_subst
(
inflater
,
&
nv
,
subindex
);
}
else
{
new_ent
=
add_hd_table_incremental
(
inflater
,
&
nv
);
}
if
(
--
ent
->
ref
==
0
)
{
nghttp2_hd_entry_free
(
ent
);
free
(
ent
);
...
...
@@ -989,102 +1007,9 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
rv
=
emit_indexed_header
(
inflater
,
&
nva_out
,
new_ent
);
}
else
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
}
if
(
rv
<
0
)
{
goto
fail
;
}
}
else
if
(
c
==
0
)
{
/* Literal Header with substitution indexing - new name */
nghttp2_hd_entry
*
new_ent
;
nghttp2_nv
nv
;
ssize_t
namelen
,
valuelen
,
subindex
;
if
(
++
in
==
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
in
=
decode_length
(
&
namelen
,
in
,
last
,
8
);
if
(
namelen
<
0
||
in
+
namelen
>
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
if
(
!
nghttp2_check_header_name
(
in
,
namelen
))
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
nv
.
name
=
in
;
in
+=
namelen
;
in
=
decode_length
(
&
subindex
,
in
,
last
,
8
);
if
(
subindex
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
in
=
decode_length
(
&
valuelen
,
in
,
last
,
8
);
if
(
valuelen
<
0
||
in
+
valuelen
>
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
nv
.
value
=
in
;
nv
.
namelen
=
namelen
;
nv
.
valuelen
=
valuelen
;
in
+=
valuelen
;
nghttp2_downcase
(
nv
.
name
,
nv
.
namelen
);
new_ent
=
add_hd_table_subst
(
inflater
,
&
nv
,
subindex
);
if
(
new_ent
)
{
rv
=
emit_indexed_header
(
inflater
,
&
nva_out
,
new_ent
);
if
(
rv
<
0
)
{
goto
fail
;
}
}
else
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
}
else
{
/* Literal Header with substitution indexing - indexed name */
nghttp2_hd_entry
*
ent
,
*
new_ent
;
ssize_t
valuelen
;
ssize_t
index
,
subindex
;
nghttp2_nv
nv
;
in
=
decode_length
(
&
index
,
in
,
last
,
6
);
if
(
index
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
--
index
;
if
(
inflater
->
hd_tablelen
<=
index
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
ent
=
inflater
->
hd_table
[
index
];
in
=
decode_length
(
&
subindex
,
in
,
last
,
8
);
if
(
subindex
<
0
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
in
=
decode_length
(
&
valuelen
,
in
,
last
,
8
);
if
(
valuelen
<
0
||
in
+
valuelen
>
last
)
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
goto
fail
;
}
++
ent
->
ref
;
nv
.
name
=
ent
->
nv
.
name
;
nv
.
namelen
=
ent
->
nv
.
namelen
;
nv
.
value
=
in
;
nv
.
valuelen
=
valuelen
;
in
+=
valuelen
;
new_ent
=
add_hd_table_subst
(
inflater
,
&
nv
,
subindex
);
if
(
--
ent
->
ref
==
0
)
{
nghttp2_hd_entry_free
(
ent
);
free
(
ent
);
}
if
(
new_ent
)
{
rv
=
emit_indexed_header
(
inflater
,
&
nva_out
,
new_ent
);
if
(
rv
<
0
)
{
goto
fail
;
}
}
else
{
rv
=
NGHTTP2_ERR_HEADER_COMP
;
if
(
rv
!=
0
)
{
goto
fail
;
}
}
...
...
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