X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex.c;h=52313cc594dd5c6a8b3825742d9368b3eac3155d;hb=85059e82790a28bc81fdcd22ec5cf6d5c178496e;hp=01d87157319005e62bf3a75682995eb2ba4e9b80;hpb=6373daf9d9fdd9e24d2c657abf0625337f9b3a24;p=ashd.git diff --git a/src/dirplex.c b/src/dirplex.c index 01d8715..52313cc 100644 --- a/src/dirplex.c +++ b/src/dirplex.c @@ -302,6 +302,9 @@ static struct config *getconfig(char *path) cf->mtime = mtime; cf->lastck = now; cf->next = cflist; + cf->prev = NULL; + if(cflist != NULL) + cflist->prev = cf; cflist = cf; return(cf); } @@ -445,7 +448,7 @@ static void handledir(struct hthead *req, int fd, char *path) while((dent = readdir(dir)) != NULL) { if((p = strchr(dent->d_name, '.')) == NULL) continue; - if(strncmp(dent->d_name, inm, p - dent->d_name)) + if(strncmp(dent->d_name, inm, strlen(inm))) continue; ipath = sprintf2("%s/%s", path, dent->d_name); if(stat(ipath, &sb) || !S_ISREG(sb.st_mode)) { @@ -491,6 +494,12 @@ static void serve(struct hthead *req, int fd) } else { *(p2++) = 0; } + if((tmp = unquoteurl(p)) == NULL) { + simpleerror(fd, 400, "Bad Request", "The requested URL contains an invalid escape sequence."); + goto fail; + } + strcpy(p, tmp); + free(tmp); if(!*p) { if(p2 == NULL) {