Skip to content

Commit 8959e64

Browse files
committed
use an internal strcmp
1 parent 91b49f1 commit 8959e64

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ static char* _strchr(char* str, char c) {
213213
return nullptr;
214214
}
215215

216+
static int _strcmp(const char *s1, const char *s2) {
217+
while (true) {
218+
unsigned c1 = *s1;
219+
unsigned c2 = *s2;
220+
if (c1 != c2) return (c1 < c2) ? -1 : 1;
221+
if (c1 == 0) break;
222+
s1++;
223+
s2++;
224+
}
225+
return 0;
226+
}
227+
216228
static void _memset(void *p, int value, size_t sz) {
217229
for (size_t i = 0; i < sz; ++i)
218230
((char*)p)[i] = (char)value;
@@ -1234,7 +1246,7 @@ uptr InternalGetProcAddress(void *module, const char *func_name) {
12341246

12351247
for (DWORD i = 0; i < exports->NumberOfNames; i++) {
12361248
RVAPtr<char> name(module, names[i]);
1237-
if (!strcmp(func_name, name)) {
1249+
if (!_strcmp(func_name, name)) {
12381250
DWORD index = ordinals[i];
12391251
RVAPtr<char> func(module, functions[index]);
12401252

@@ -1291,7 +1303,7 @@ bool OverrideFunction(
12911303
// This is the last DLL, i.e. NTDLL. It exports some functions that
12921304
// we only want to override in the CRT.
12931305
for (const char *ignored : kNtDllIgnore) {
1294-
if (strcmp(func_name, ignored) == 0)
1306+
if (_strcmp(func_name, ignored) == 0)
12951307
return hooked;
12961308
}
12971309
}
@@ -1349,7 +1361,7 @@ bool OverrideImportedFunction(const char *module_to_patch,
13491361
RVAPtr<IMAGE_IMPORT_BY_NAME> import_by_name(
13501362
module, name_table->u1.ForwarderString);
13511363
const char *funcname = &import_by_name->Name[0];
1352-
if (strcmp(funcname, function_name) == 0)
1364+
if (_strcmp(funcname, function_name) == 0)
13531365
break;
13541366
}
13551367
}

0 commit comments

Comments
 (0)