Skip to content

Commit e0c7bb7

Browse files
Update input.c
1 parent 9cfc283 commit e0c7bb7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

code/logic/input.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <stdlib.h>
2222
#include <stdarg.h>
2323
#include <limits.h>
24+
#include <math.h>
2425

2526
#ifdef __WIN32
2627
#include <windows.h>
@@ -307,7 +308,7 @@ int fossil_io_validate_is_suspicious_user(const char *input) {
307308
const char *bad_keywords[] = {"bot", "test", "fake", "spam", "zzz", "null", "admin"};
308309
size_t nkeys = sizeof(bad_keywords) / sizeof(bad_keywords[0]);
309310
for (size_t i = 0; i < nkeys; i++) {
310-
if (strcasestr(input, bad_keywords[i]) != NULL) {
311+
if (fossil_io_cstring_case_search(input, bad_keywords[i]) != NULL) {
311312
return 1;
312313
}
313314
}
@@ -339,7 +340,7 @@ int fossil_io_validate_is_disposable_email(const char *input) {
339340
size_t ndomains = sizeof(disposable_domains) / sizeof(disposable_domains[0]);
340341

341342
for (size_t i = 0; i < ndomains; i++) {
342-
if (strcasecmp(at + 1, disposable_domains[i]) == 0) {
343+
if (fossil_io_cstring_case_compare(at + 1, disposable_domains[i]) == 0) {
343344
return 1;
344345
}
345346
}
@@ -356,7 +357,7 @@ int fossil_io_validate_is_suspicious_bot(const char *input) {
356357
size_t nsignatures = sizeof(bot_signatures) / sizeof(bot_signatures[0]);
357358

358359
for (size_t i = 0; i < nsignatures; i++) {
359-
if (strcasestr(input, bot_signatures[i]) != NULL) {
360+
if (fossil_io_cstring_case_search(input, bot_signatures[i]) != NULL) {
360361
return 1;
361362
}
362363
}
@@ -396,7 +397,7 @@ int fossil_io_validate_is_weak_password(const char *password,
396397
};
397398
size_t weak_count = sizeof(weak_list) / sizeof(weak_list[0]);
398399
for (size_t i = 0; i < weak_count; i++) {
399-
if (strcasecmp(password, weak_list[i]) == 0) {
400+
if (fossil_io_cstring_case_compare(password, weak_list[i]) == 0) {
400401
return 1;
401402
}
402403
}
@@ -413,10 +414,10 @@ int fossil_io_validate_is_weak_password(const char *password,
413414
}
414415

415416
// 5. Prevent reuse of username or email as password
416-
if (username && *username && strcasecmp(password, username) == 0) {
417+
if (username && *username && fossil_io_cstring_case_compare(password, username) == 0) {
417418
return 1;
418419
}
419-
if (email && *email && strcasecmp(password, email) == 0) {
420+
if (email && *email && fossil_io_cstring_case_compare(password, email) == 0) {
420421
return 1;
421422
}
422423

0 commit comments

Comments
 (0)