Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace strlen upper bound with checks for '\0' #1018

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions common/wwstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,22 @@ inline static void _splitpath(const char* path, char* drive, char* dir, char* fn
return;
}

for (int i = 0; i < strlen(path); i++) {
if (path[i] == '.') {
strcpy(ext, path + i + 1);
while (*path != '\0') {
if (*path == '.') {
strcpy(ext, path + 1);
break;
}

++path;
}
}

inline static char* strupr(char* str)
{
for (int i = 0; i < strlen(str); i++)
str[i] = toupper(str[i]);
while (*str != '\0') {
*str = toupper(*str);
++str;
}
return str;
}

Expand All @@ -278,10 +282,9 @@ inline static void strrev(char* str)

inline static void _strlwr(char* str)
{
int len = strlen(str);

for (int i = 0; i < len; i++) {
str[i] = tolower(str[i]);
while (*str != '\0') {
*str = tolower(*str);
++str;
}
}

Expand Down
5 changes: 3 additions & 2 deletions redalert/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,9 @@ uint32_t SessionClass::Compute_Unique_ID(void)
//------------------------------------------------------------------------
path = getenv("PATH");
if (path) {
for (i = 0; i < strlen(path); i++) {
Add_CRC(&id, (unsigned int)path[i]);
while (*path != '\0') {
Add_CRC(&id, (unsigned int)(*path));
++path;
}
}

Expand Down