forked from solene/vger
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:
parent
fa99a06619
commit
f49916a1c2
5
main.c
5
main.c
|
@ -308,7 +308,10 @@ cgi(const char *cgicmd)
|
||||||
void
|
void
|
||||||
strip_trailing_slash(char *path)
|
strip_trailing_slash(char *path)
|
||||||
{
|
{
|
||||||
size_t end = strlen(path) - 1;
|
size_t end = strlen(path);
|
||||||
|
if (end == 0)
|
||||||
|
return;
|
||||||
|
end--;
|
||||||
while (path[end] == '/')
|
while (path[end] == '/')
|
||||||
path[end--] = '\0';
|
path[end--] = '\0';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue