diff --git a/quark.c b/quark.c index 755b94d..14044ae 100644 --- a/quark.c +++ b/quark.c @@ -568,9 +568,12 @@ sendresponse(int fd, struct request *r) for (i = 0; i < LEN(vhost); i++) { /* switch to vhost directory if there is a match */ if (!regexec(&vhost[i].re, r->field[REQ_HOST], 0, - NULL, 0) && chdir(vhost[i].dir) < 0) { - return sendstatus(fd, (errno == EACCES) ? - S_FORBIDDEN : S_NOT_FOUND); + NULL, 0) { + if (chdir(vhost[i].dir) < 0) { + return sendstatus(fd, (errno == EACCES) + ? S_FORBIDDEN : S_NOT_FOUND); + } + break; } } }