forked from solene/vger
fix cgi checking
make sure to look for files *after* the cgidir bit. should now work with virtualhost and cgi, as it doesn't just blindly find the first slash.
This commit is contained in:
parent
bb4be69207
commit
99f4310188
13
main.c
13
main.c
|
@ -38,6 +38,7 @@ void echdir (const char *);
|
|||
void status (const int, const char *);
|
||||
void status_redirect(const int, const char *);
|
||||
void status_error(const int, const char *);
|
||||
void strip_trailing_slash(char *path);
|
||||
int uridecode (char *);
|
||||
|
||||
|
||||
|
@ -304,6 +305,14 @@ cgi(const char *cgicmd)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
strip_trailing_slash(char *path)
|
||||
{
|
||||
size_t len = strlen(path);
|
||||
while (path[len - 1] == '/')
|
||||
path[len-- - 1] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -461,13 +470,15 @@ main(int argc, char **argv)
|
|||
/* find the string of cgidir without chroot_dir prefix */
|
||||
char tmp [PATH_MAX] = {'\0'};
|
||||
char *cgipp;
|
||||
strip_trailing_slash(chroot_dir);
|
||||
strip_trailing_slash(cgidir);
|
||||
estrlcpy(tmp, cgidir + strlen(chroot_dir), sizeof(tmp));
|
||||
cgipp = tmp;
|
||||
if (tmp[0] == '/')
|
||||
cgipp++;
|
||||
|
||||
if (docgi && strncmp(dir, cgipp, strlen(cgipp)) == 0) {
|
||||
pos = strchr(dir, '/');
|
||||
pos = strchr(dir+strlen(cgipp), '/');
|
||||
} else {
|
||||
pos = strrchr(dir, '/');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue