Fix the style a bit and prevent out-of-bounds index access for vhost[]
This commit is contained in:
parent
d3c1091669
commit
d7f5c6029e
1 changed files with 3 additions and 4 deletions
7
quark.c
7
quark.c
|
@ -566,10 +566,9 @@ sendresponse(int fd, struct request *r)
|
||||||
/* match vhost */
|
/* match vhost */
|
||||||
if (vhosts) {
|
if (vhosts) {
|
||||||
for (i = 0; i < LEN(vhost); i++) {
|
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,
|
if (!regexec(&vhost[i].re, r->field[REQ_HOST], 0,
|
||||||
NULL, 0) &&
|
NULL, 0) && chdir(vhost[i].dir) < 0) {
|
||||||
/* switch to vhost directory */
|
|
||||||
chdir(vhost[i].dir) < 0) {
|
|
||||||
return sendstatus(fd, (errno == EACCES) ?
|
return sendstatus(fd, (errno == EACCES) ?
|
||||||
S_FORBIDDEN : S_NOT_FOUND);
|
S_FORBIDDEN : S_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +605,7 @@ sendresponse(int fd, struct request *r)
|
||||||
|
|
||||||
/* redirect if targets differ or host is non-canonical */
|
/* redirect if targets differ or host is non-canonical */
|
||||||
if (strcmp(r->target, realtarget) || (vhosts && r->field[REQ_HOST][0] &&
|
if (strcmp(r->target, realtarget) || (vhosts && r->field[REQ_HOST][0] &&
|
||||||
strcmp(r->field[REQ_HOST], vhost[i].name))) {
|
i < LEN(vhost) && strcmp(r->field[REQ_HOST], vhost[i].name))) {
|
||||||
/* do we need to add a port to the Location? */
|
/* do we need to add a port to the Location? */
|
||||||
hasport = strcmp(port, "80");
|
hasport = strcmp(port, "80");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue