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
f0a09160
Commit
f0a09160
authored
Oct 02, 2021
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuzzers: use updated hash functions
parent
923364c5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
fuzzers/commit_graph_fuzzer.c
+6
-3
fuzzers/midx_fuzzer.c
+6
-3
No files found.
fuzzers/commit_graph_fuzzer.c
View file @
f0a09160
...
...
@@ -34,6 +34,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
git_commit_graph_file
file
=
{{
0
}};
git_commit_graph_entry
e
;
git_buf
commit_graph_buf
=
GIT_BUF_INIT
;
unsigned
char
hash
[
GIT_HASH_SHA1_SIZE
];
git_oid
oid
=
{{
0
}};
bool
append_hash
=
false
;
...
...
@@ -50,14 +51,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size
-=
4
;
if
(
append_hash
)
{
if
(
git_buf_init
(
&
commit_graph_buf
,
size
+
sizeof
(
oid
)
)
<
0
)
if
(
git_buf_init
(
&
commit_graph_buf
,
size
+
GIT_HASH_SHA1_SIZE
)
<
0
)
goto
cleanup
;
if
(
git_hash_buf
(
&
oid
,
data
,
size
)
<
0
)
{
if
(
git_hash_buf
(
hash
,
data
,
size
,
GIT_HASH_ALGORITHM_SHA1
)
<
0
)
{
fprintf
(
stderr
,
"Failed to compute the SHA1 hash
\n
"
);
abort
();
}
memcpy
(
commit_graph_buf
.
ptr
,
data
,
size
);
memcpy
(
commit_graph_buf
.
ptr
+
size
,
&
oid
,
sizeof
(
oid
));
memcpy
(
commit_graph_buf
.
ptr
+
size
,
hash
,
GIT_HASH_SHA1_SIZE
);
memcpy
(
oid
.
id
,
hash
,
GIT_OID_RAWSZ
);
}
else
{
git_buf_attach_notowned
(
&
commit_graph_buf
,
(
char
*
)
data
,
size
);
}
...
...
fuzzers/midx_fuzzer.c
View file @
f0a09160
...
...
@@ -34,6 +34,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
git_midx_file
idx
=
{{
0
}};
git_midx_entry
e
;
git_buf
midx_buf
=
GIT_BUF_INIT
;
unsigned
char
hash
[
GIT_HASH_SHA1_SIZE
];
git_oid
oid
=
{{
0
}};
bool
append_hash
=
false
;
...
...
@@ -50,14 +51,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size
-=
4
;
if
(
append_hash
)
{
if
(
git_buf_init
(
&
midx_buf
,
size
+
sizeof
(
oid
)
)
<
0
)
if
(
git_buf_init
(
&
midx_buf
,
size
+
GIT_HASH_SHA1_SIZE
)
<
0
)
goto
cleanup
;
if
(
git_hash_buf
(
&
oid
,
data
,
size
)
<
0
)
{
if
(
git_hash_buf
(
hash
,
data
,
size
,
GIT_HASH_ALGORITHM_SHA1
)
<
0
)
{
fprintf
(
stderr
,
"Failed to compute the SHA1 hash
\n
"
);
abort
();
}
memcpy
(
midx_buf
.
ptr
,
data
,
size
);
memcpy
(
midx_buf
.
ptr
+
size
,
&
oid
,
sizeof
(
oid
));
memcpy
(
midx_buf
.
ptr
+
size
,
hash
,
GIT_HASH_SHA1_SIZE
);
memcpy
(
oid
.
id
,
hash
,
GIT_OID_RAWSZ
);
}
else
{
git_buf_attach_notowned
(
&
midx_buf
,
(
char
*
)
data
,
size
);
}
...
...
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