check for 0 length string in strip_trailing_slash

size_t is unsigned, so if strlen returned 0, path[end] would try to
access something unexpected
This commit is contained in:
aabacchus 2022-03-26 20:22:56 +00:00
parent fa99a06619
commit f49916a1c2
Signed by: phoebos
GPG Key ID: B02F7D053AC351D3
1 changed files with 4 additions and 1 deletions

5
main.c
View File

@ -308,7 +308,10 @@ cgi(const char *cgicmd)
void
strip_trailing_slash(char *path)
{
size_t end = strlen(path) - 1;
size_t end = strlen(path);
if (end == 0)
return;
end--;
while (path[end] == '/')
path[end--] = '\0';
}