Support filename pattern matching in whitelist

Allow the whitelist specified by AFL_LLVM_WHITELIST contain entries with
UNIX shell-style wildcard pattern matching.
This commit is contained in:
Sebastian Österlund
2020-05-29 10:51:34 +02:00
parent 5e4cd05e04
commit 0cedc8014b

View File

@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <fnmatch.h>
#include <list> #include <list>
#include <string> #include <string>
@ -155,9 +156,8 @@ bool isInWhitelist(llvm::Function *F) {
* specified in the list. */ * specified in the list. */
if (instFilename.str().length() >= it->length()) { if (instFilename.str().length() >= it->length()) {
if (instFilename.str().compare( if (fnmatch((*it).c_str(),
instFilename.str().length() - it->length(), it->length(), instFilename.str().c_str(), FNM_PATHNAME) == 0) {
*it) == 0) {
return true; return true;