Skip to content

Commit

Permalink
Add fuzzer stub for evalstring in sh(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
plusun committed Jun 19, 2018
1 parent 5813323 commit 330d96a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bin/sh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern int etext();

STATIC void read_profile(const char *);

#ifndef ENABLE_FUZZER
/*
* Main routine. We initialize things, parse the arguments, execute
* profiles if we're a login shell, and then call cmdloop to execute
Expand Down Expand Up @@ -246,7 +247,17 @@ main(int argc, char **argv)
exitshell(exitstatus);
/* NOTREACHED */
}

#else
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);

int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size == 0 || Data[Size - 1] != '\0') {
return 0;
}
evalstring((const char *)Data, 0);
return 0;
}
#endif

/*
* Read and execute commands. "Top" is nonzero for the top level command
Expand Down

0 comments on commit 330d96a

Please sign in to comment.