about summary refs log tree commit diff
path: root/llvm_mode/afl-llvm-common.cc
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-29 16:21:54 +0200
committerGitHub <noreply@github.com>2020-05-29 16:21:54 +0200
commit255594ba3a520ecb555e5c6ef4493f2508c63706 (patch)
tree757b6cad45a463e87dcf0f606c4bebe6fb241720 /llvm_mode/afl-llvm-common.cc
parenta550df43011e41ff5d3ba6c125a410d4374211fc (diff)
parent8bb0232ace731c596e9e4e083a048784e35221cd (diff)
downloadafl++-255594ba3a520ecb555e5c6ef4493f2508c63706.tar.gz
Merge pull request #385 from sirmc/dev
Support UNIX-style wildcards in AFL_LLVM_WHITELIST file
Diffstat (limited to 'llvm_mode/afl-llvm-common.cc')
-rw-r--r--llvm_mode/afl-llvm-common.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm_mode/afl-llvm-common.cc b/llvm_mode/afl-llvm-common.cc
index 35eabbf0..6c7222cd 100644
--- a/llvm_mode/afl-llvm-common.cc
+++ b/llvm_mode/afl-llvm-common.cc
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/time.h>
+#include <fnmatch.h>
 
 #include <list>
 #include <string>
@@ -152,12 +153,13 @@ bool isInWhitelist(llvm::Function *F) {
         /* We don't check for filename equality here because
          * filenames might actually be full paths. Instead we
          * check that the actual filename ends in the filename
-         * specified in the list. */
+         * specified in the list. We also allow UNIX-style pattern
+         * matching */
+
         if (instFilename.str().length() >= it->length()) {
 
-          if (instFilename.str().compare(
-                  instFilename.str().length() - it->length(), it->length(),
-                  *it) == 0) {
+          if (fnmatch(("*" + *it).c_str(), instFilename.str().c_str(), 0) ==
+              0) {
 
             return true;
 
@@ -189,12 +191,13 @@ bool isInWhitelist(llvm::Function *F) {
         /* We don't check for filename equality here because
          * filenames might actually be full paths. Instead we
          * check that the actual filename ends in the filename
-         * specified in the list. */
+         * specified in the list. We also allow UNIX-style pattern
+         * matching */
+
         if (instFilename.str().length() >= it->length()) {
 
-          if (instFilename.str().compare(
-                  instFilename.str().length() - it->length(), it->length(),
-                  *it) == 0) {
+          if (fnmatch(("*" + *it).c_str(), instFilename.str().c_str(), 0) ==
+              0) {
 
             return true;