diff --git a/src/chat/misc.c b/src/chat/misc.c index be1e32b..f30bfb4 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -165,7 +165,7 @@ void *read_socket_raw_thread(void *socket) void remove_json_syntax_characters(char *text) { - for (size_t i = 0; i < strlen(text); i++) //TODO: DO SOMETHING MORE + for (int i = 0; text[i] != '\0'; i++) //TODO: DO SOMETHING MORE { if (text[i] == '\"') { @@ -176,7 +176,7 @@ void remove_json_syntax_characters(char *text) void lowercase(char *string) { - for (unsigned long i = 0; i < strlen(string); i++) + for (int i = 0; string[i] != '\0'; i++) { string[i] = tolower(string[i]); } @@ -201,7 +201,7 @@ why2_bool check_username(char *username) if (username_equal(username, WHY2_CHAT_SERVER_USERNAME)) return 0; //DISABLE 'server' USERNAME if (username_equal(username, WHY2_DEFAULT_USERNAME)) return 0; //DISABLE 'anon' USERNAME DUE TO ONE USERNAME PER SERVER - for (unsigned long i = 0; i < strlen(username); i++) + for (int i = 0; username[i] != '\0'; i++) { if (!((username[i] >= 48 && username[i] <= 57) || (username[i] >= 65 && username[i] <= 90) || //CHECK ONLY FOR a-Z & 0-9 @@ -488,7 +488,7 @@ void *why2_communicate_thread(void *arg) raw_output = why2_strdup(""); //REMOVE CONTROL CHARACTERS FROM raw - for (size_t i = 0; i < strlen(raw); i++) + for (int i = 0; raw[i] != '\0'; i++) { if (raw[i] == '\\') raw[i] = '/'; } diff --git a/src/core/lib/decrypter.c b/src/core/lib/decrypter.c index 54ac32a..211ddb6 100644 --- a/src/core/lib/decrypter.c +++ b/src/core/lib/decrypter.c @@ -70,7 +70,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew) char *used_text = why2_strdup(text); //COPY text TO used_text //GET LENGTH OF returningText AND textKeyChain - for (int i = 0; i < (int) strlen(used_text); i++) + for (int i = 0; used_text[i] != '\0'; i++) { if (used_text[i] == why2_get_encryption_separator()) numberBuffer++; } @@ -90,7 +90,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew) numberBuffer = 0; //GET LENGTH OF EACH CHARACTER - for (int j = 0; j < (int) strlen(used_text); j++) + for (int j = 0; used_text[i] != '\0'; j++) { if (used_text[j] == why2_get_encryption_separator()) break; @@ -106,7 +106,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew) } //LOAD textBuffer - for (int j = 0; j < (int) strlen(used_text); j++) + for (int j = 0; used_text[i] != '\0'; j++) { textBuffer[j] = used_text[j]; diff --git a/src/core/lib/encrypter.c b/src/core/lib/encrypter.c index 26ae7ba..fdd64e3 100644 --- a/src/core/lib/encrypter.c +++ b/src/core/lib/encrypter.c @@ -79,13 +79,13 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew) why2_generate_text_key_chain(key, textKeyChain, strlen(text)); //ACTUALLY ENCRYPT TEXT - for (int i = 0; i < (int) strlen(text); i++) + for (int i = 0; text[i] != '\0'; i++) { textKeyChain[i] = why2_get_encryption_operation()(textKeyChain[i], (int) text[i]); } //COUNT REQUIRED SIZE FOR returningText - for (int i = 0; i < (int) strlen(text); i++) + for (int i = 0; text[i] != '\0'; i++) { numberBuffer += why2_count_int_length(textKeyChain[i]); } @@ -94,7 +94,7 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew) returningText = why2_calloc(numberBuffer + strlen(text), sizeof(char)); //LOAD returningText - for (int i = 0; i < (int) strlen(text); i++) + for (int i = 0; text[i] != '\0'; i++) { numberBuffer = sizeof(int) * why2_count_int_length(textKeyChain[i]); diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 94958cb..52536e5 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -119,7 +119,7 @@ void why2_write_log(int loggerFile, char *logMessage) //COPY logMessage without '\n' char *logMessageUsed = why2_strdup(logMessage); - for (int i = 0; i < (int) strlen(logMessageUsed); i++) + for (int i = 0; logMessageUsed[i] != '\0'; i++) { if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0'; }