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
416aafd1
Commit
416aafd1
authored
Oct 09, 2018
by
Nelson Elhage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuzzers: Port config_file_fuzzer to the new in-memory backend
parent
2d449a11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
fuzzers/config_file_fuzzer.c
+18
-25
No files found.
fuzzers/config_file_fuzzer.c
View file @
416aafd1
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
*/
*/
#include <git2.h>
#include <git2.h>
#include "config_backend.h"
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
...
@@ -25,9 +26,6 @@ int foreach_cb(const git_config_entry *entry, void *payload)
...
@@ -25,9 +26,6 @@ int foreach_cb(const git_config_entry *entry, void *payload)
return
0
;
return
0
;
}
}
static
char
path
[]
=
"/tmp/git.XXXXXX"
;
static
int
fd
=
-
1
;
int
LLVMFuzzerInitialize
(
int
*
argc
,
char
***
argv
)
int
LLVMFuzzerInitialize
(
int
*
argc
,
char
***
argv
)
{
{
UNUSED
(
argc
);
UNUSED
(
argc
);
...
@@ -35,10 +33,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
...
@@ -35,10 +33,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
if
(
git_libgit2_init
()
<
0
)
if
(
git_libgit2_init
()
<
0
)
abort
();
abort
();
fd
=
mkstemp
(
path
);
if
(
fd
<
0
)
{
abort
();
}
return
0
;
return
0
;
}
}
...
@@ -46,30 +40,29 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
...
@@ -46,30 +40,29 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
{
git_config
*
cfg
=
NULL
;
git_config
*
cfg
=
NULL
;
git_config_backend
*
backend
=
NULL
;
int
err
=
0
;
int
err
=
0
;
size_t
total
=
0
;
if
(
ftruncate
(
fd
,
0
)
!=
0
)
{
err
=
git_config_new
(
&
cfg
);
abort
();
if
(
err
!=
0
)
{
}
goto
out
;
if
(
lseek
(
fd
,
0
,
SEEK_SET
)
!=
0
)
{
abort
();
}
}
while
(
total
<
size
)
{
err
=
git_config_backend_from_string
(
&
backend
,
(
const
char
*
)
data
,
size
);
ssize_t
written
=
write
(
fd
,
data
,
size
);
if
(
err
!=
0
)
{
if
(
written
<
0
&&
errno
!=
EINTR
)
goto
out
;
abort
();
if
(
written
<
0
)
continue
;
total
+=
written
;
}
}
err
=
git_config_add_backend
(
cfg
,
backend
,
0
,
NULL
,
0
);
err
=
git_config_open_ondisk
(
&
cfg
,
path
);
if
(
err
!=
0
)
{
if
(
err
==
0
)
{
goto
out
;
git_config_foreach
(
cfg
,
foreach_cb
,
NULL
);
git_config_free
(
cfg
);
}
}
// Now owned by the config
backend
=
NULL
;
git_config_foreach
(
cfg
,
foreach_cb
,
NULL
);
out:
git_config_backend_free
(
backend
);
git_config_free
(
cfg
);
return
0
;
return
0
;
}
}
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