File tree Expand file tree Collapse file tree 1 file changed +27
-11
lines changed
Expand file tree Collapse file tree 1 file changed +27
-11
lines changed Original file line number Diff line number Diff line change 55#include <unistd.h>
66#include <limits.h>
77
8+ #define UNUSED (x ) (void)(x)
9+
810int foreach_cb (const git_config_entry * entry , void * payload )
911{
12+ UNUSED (entry );
13+ UNUSED (payload );
14+
1015 return 0 ;
1116}
1217
13- int LLVMFuzzerTestOneInput (const uint8_t * data , size_t size )
18+ static char path [] = "/tmp/git.XXXXXX" ;
19+ static int fd = -1 ;
20+
21+ int LLVMFuzzerInitialize (int * argc , char * * * argv )
1422{
15- static int fd = -1 ;
16- static char path [] = "/tmp/git.XXXXXX" ;
23+ UNUSED (argc );
24+ UNUSED (argv );
25+
26+ if (git_libgit2_init () < 0 )
27+ abort ();
28+ fd = mkstemp (path );
1729 if (fd < 0 ) {
18- git_libgit2_init ();
19- fd = mkstemp (path );
20- if (fd < 0 ) {
21- abort ();
22- }
30+ abort ();
2331 }
32+
33+ return 0 ;
34+ }
35+
36+ int LLVMFuzzerTestOneInput (const uint8_t * data , size_t size )
37+ {
38+ git_config * cfg = NULL ;
39+ int err = 0 ;
40+
2441 if (ftruncate (fd , 0 ) != 0 ) {
2542 abort ();
2643 }
2744 if (lseek (fd , 0 , SEEK_SET ) != 0 ) {
2845 abort ();
2946 }
30- if (write (fd , data , size ) != size ) {
47+ if (( size_t ) write (fd , data , size ) != size ) {
3148 abort ();
3249 }
3350
34- git_config * cfg ;
35- int err = git_config_open_ondisk (& cfg , path );
51+ err = git_config_open_ondisk (& cfg , path );
3652 if (err == 0 ) {
3753 git_config_foreach (cfg , foreach_cb , NULL );
3854 git_config_free (cfg );
You can’t perform that action at this time.
0 commit comments