Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
1b162c9e
Commit
1b162c9e
authored
Jan 16, 2024
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
Fixing: applying non-zero offset to null pointer when reading a stream with 0 size
parent
1c84ba3f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!26
Adapt cmp_tool to the chunk decompression
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/decompress/read_bitstream.h
+9
-4
9 additions, 4 deletions
lib/decompress/read_bitstream.h
with
9 additions
and
4 deletions
lib/decompress/read_bitstream.h
+
9
−
4
View file @
1b162c9e
...
...
@@ -45,6 +45,7 @@
#include
<string.h>
#include
"../common/byteorder.h"
#include
"../common/compiler.h"
...
...
@@ -123,14 +124,18 @@ static __inline uint64_t bit_read_unaligned_64be(const void *ptr)
static
__inline
size_t
bit_init_decoder
(
struct
bit_decoder
*
dec
,
const
void
*
buf
,
size_t
buf_size
)
{
assert
(
dec
!=
NULL
);
assert
(
buf
!=
NULL
);
dec
->
cursor
=
(
const
uint8_t
*
)
buf
;
if
(
buf_size
<
1
)
{
memset
(
dec
,
0
,
sizeof
(
*
dec
));
dec
->
bits_consumed
=
sizeof
(
dec
->
bit_container
)
*
8
;
dec
->
bit_container
=
0
;
dec
->
limit_ptr
=
(
const
uint8_t
*
)
buf
;
return
0
;
}
dec
->
cursor
=
(
const
uint8_t
*
)
buf
;
if
(
buf_size
>=
sizeof
(
dec
->
bit_container
))
{
/* normal case */
dec
->
bits_consumed
=
0
;
dec
->
bit_container
=
bit_read_unaligned_64be
(
dec
->
cursor
);
...
...
@@ -320,7 +325,7 @@ static __inline int bit_refill(struct bit_decoder *dec)
{
unsigned
int
const
bytes_consumed
=
dec
->
bits_consumed
>>
3
;
if
(
dec
->
bits_consumed
>
sizeof
(
dec
->
bit_container
)
*
8
)
if
(
unlikely
(
dec
->
bits_consumed
>
sizeof
(
dec
->
bit_container
)
*
8
)
)
return
BIT_OVERFLOW
;
if
(
dec
->
cursor
+
bytes_consumed
<
dec
->
limit_ptr
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment