Skip to content

Commit

Permalink
hfuzz-cc/libhfuzz/memorycmp: wrappers for sqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Jul 20, 2024
1 parent e13230f commit 02f8a7f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ static bool fuzz_fetchInput(run_t* run) {
return false;
}
} else if (run->global->exe.feedbackMutateCommand) {
if (!input_prepareStaticFile(run, true, false)) {
if (!input_prepareStaticFile(run, /* rewind= */ true, /* mangle= */ false)) {
LOG_E("input_prepareStaticFile() failed");
return false;
}
} else if (!input_prepareStaticFile(run, true /* rewind */, true)) {
} else if (!input_prepareStaticFile(run, /* rewind= */ true, /* mangle= */ true)) {
LOG_E("input_prepareStaticFile() failed");
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions hfuzz_cc/hfuzz-cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ static void commonPreOpts(int* j, char** args) {
args[(*j)++] = "-mllvm";
args[(*j)++] = "-inline-threshold=1000";
}

args[(*j)++] = "-fno-builtin";
args[(*j)++] = "-fno-omit-frame-pointer";
args[(*j)++] = "-D__NO_STRING_INLINES";
Expand Down Expand Up @@ -506,6 +507,10 @@ static int ldMode(int argc, char** argv) {
args[j++] = "-Wl,--wrap=Curl_safe_strcasecompare";
args[j++] = "-Wl,--wrap=Curl_strncasecompare";
args[j++] = "-Wl,--wrap=curl_strnequal";
/* SQLite3 */
args[j++] = "-Wl,--wrap=sqlite3_stricmp";
args[j++] = "-Wl,--wrap=sqlite3_strnicmp";
args[j++] = "-Wl,--wrap=sqlite3StrICmp";
#endif /* _HF_ARCH_DARWIN */

/* Pull modules defining the following symbols (if they exist) */
Expand Down
12 changes: 12 additions & 0 deletions libhfuzz/memorycmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,18 @@ HF_WEAK_WRAP(int, curl_strnequal, const char* first, const char* second, size_t
return 0;
}

/* SQLite3 wrappers */
HF_WEAK_WRAP(int, sqlite3_stricmp, const char* s1, const char* s2) {
return HF_strcasecmp(s1, s2, tolower, (uintptr_t)__builtin_return_address(0));
}
HF_WEAK_WRAP(int, sqlite3StrICmp, const char* s1, const char* s2) {
return HF_strcasecmp(s1, s2, tolower, (uintptr_t)__builtin_return_address(0));
}
HF_WEAK_WRAP(int, sqlite3_strnicmp, const char* s1, const char* s2, size_t len) {
return HF_strncasecmp(
s1, s2, len, tolower, /* constfb= */ true, (uintptr_t)__builtin_return_address(0));
}

/* C++ wrappers */
int _ZNSt11char_traitsIcE7compareEPKcS2_m(const char* s1, const char* s2, size_t count) {
return HF_memcmp(s1, s2, count, instrumentConstAvail(), (uintptr_t)__builtin_return_address(0));
Expand Down

0 comments on commit 02f8a7f

Please sign in to comment.