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
12144acf
Commit
12144acf
authored
Dec 18, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp2_hd: Check last byte of huffman encoded byte string strictly
parent
cd5043f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
lib/nghttp2_hd_huffman.c
lib/nghttp2_hd_huffman.c
+16
-8
No files found.
lib/nghttp2_hd_huffman.c
View file @
12144acf
...
...
@@ -187,6 +187,14 @@ ssize_t nghttp2_hd_huff_encode(uint8_t *dest, size_t destlen,
return
dest
-
dest_first
+
(
bitoff
>
0
);
}
static
int
check_last_byte
(
const
uint8_t
*
src
,
size_t
srclen
,
size_t
idx
,
size_t
bitoff
)
{
uint8_t
last_mask
=
(
1
<<
(
8
-
bitoff
))
-
1
;
return
idx
+
1
==
srclen
&&
bitoff
>
0
&&
(
src
[
idx
]
&
last_mask
)
==
last_mask
;
}
ssize_t
nghttp2_hd_huff_decode_count
(
const
uint8_t
*
src
,
size_t
srclen
,
nghttp2_hd_side
side
)
{
...
...
@@ -207,15 +215,15 @@ ssize_t nghttp2_hd_huff_decode_count(const uint8_t *src, size_t srclen,
int
rv
=
huff_decode
(
src
+
i
,
srclen
-
i
,
bitoff
,
huff_sym_table
,
huff_decode_table
);
if
(
rv
==
-
1
)
{
/* TODO Check prefix of EOS */
if
(
i
+
1
==
srclen
&&
bitoff
>
0
)
{
if
(
check_last_byte
(
src
,
srclen
,
i
,
bitoff
))
{
break
;
}
return
-
1
;
}
if
(
rv
==
256
)
{
/* 256 is special terminal symbol */
break
;
/* 256 is special terminal symbol and it should not encoded in
byte string. */
return
-
1
;
}
j
++
;
bitoff
+=
huff_sym_table
[
rv
].
nbits
;
...
...
@@ -246,15 +254,15 @@ ssize_t nghttp2_hd_huff_decode(uint8_t *dest, size_t destlen,
int
rv
=
huff_decode
(
src
+
i
,
srclen
-
i
,
bitoff
,
huff_sym_table
,
huff_decode_table
);
if
(
rv
==
-
1
)
{
/* TODO Check prefix of EOS */
if
(
i
+
1
==
srclen
&&
bitoff
>
0
)
{
if
(
check_last_byte
(
src
,
srclen
,
i
,
bitoff
))
{
break
;
}
return
-
1
;
}
if
(
rv
==
256
)
{
/* 256 is special terminal symbol */
break
;
/* 256 is special terminal symbol and it should not encoded in
byte string. */
return
-
1
;
}
dest
[
j
++
]
=
rv
;
bitoff
+=
huff_sym_table
[
rv
].
nbits
;
...
...
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