Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
7e8d9be0
Unverified
Commit
7e8d9be0
authored
Apr 10, 2022
by
Edward Thomson
Committed by
GitHub
Apr 10, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6260 from lhchavez/midx-fix-ub
midx: Fix an undefined behavior (left-shift signed overflow)
parents
606afeda
33b1d3fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
+0
-0
src/libgit2/midx.c
+8
-3
No files found.
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
0 → 100644
View file @
7e8d9be0
File added
src/libgit2/midx.c
View file @
7e8d9be0
...
@@ -225,8 +225,13 @@ int git_midx_parse(
...
@@ -225,8 +225,13 @@ int git_midx_parse(
chunk_hdr
=
data
+
sizeof
(
struct
git_midx_header
);
chunk_hdr
=
data
+
sizeof
(
struct
git_midx_header
);
last_chunk
=
NULL
;
last_chunk
=
NULL
;
for
(
i
=
0
;
i
<
hdr
->
chunks
;
++
i
,
chunk_hdr
+=
12
)
{
for
(
i
=
0
;
i
<
hdr
->
chunks
;
++
i
,
chunk_hdr
+=
12
)
{
chunk_offset
=
((
off64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
4
))))
<<
32
|
uint32_t
chunk_id
=
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
0
)));
((
off64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
8
))));
uint64_t
high_offset
=
((
uint64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
4
))))
&
0xffffffffu
;
uint64_t
low_offset
=
((
uint64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
8
))))
&
0xffffffffu
;
if
(
high_offset
>=
INT32_MAX
)
return
midx_error
(
"chunk offset out of range"
);
chunk_offset
=
(
off64_t
)(
high_offset
<<
32
|
low_offset
);
if
(
chunk_offset
<
last_chunk_offset
)
if
(
chunk_offset
<
last_chunk_offset
)
return
midx_error
(
"chunks are non-monotonic"
);
return
midx_error
(
"chunks are non-monotonic"
);
if
(
chunk_offset
>=
trailer_offset
)
if
(
chunk_offset
>=
trailer_offset
)
...
@@ -235,7 +240,7 @@ int git_midx_parse(
...
@@ -235,7 +240,7 @@ int git_midx_parse(
last_chunk
->
length
=
(
size_t
)(
chunk_offset
-
last_chunk_offset
);
last_chunk
->
length
=
(
size_t
)(
chunk_offset
-
last_chunk_offset
);
last_chunk_offset
=
chunk_offset
;
last_chunk_offset
=
chunk_offset
;
switch
(
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
0
)))
)
{
switch
(
chunk_id
)
{
case
MIDX_PACKFILE_NAMES_ID
:
case
MIDX_PACKFILE_NAMES_ID
:
chunk_packfile_names
.
offset
=
last_chunk_offset
;
chunk_packfile_names
.
offset
=
last_chunk_offset
;
last_chunk
=
&
chunk_packfile_names
;
last_chunk
=
&
chunk_packfile_names
;
...
...
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