From: Fredrik Tolf Date: Thu, 14 Apr 2011 13:57:57 +0000 (+0200) Subject: sendfile: Only allow GET and HEAD requests. X-Git-Tag: 0.8~11 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=6586b2b37418f8cb54c5b82bec64bfb7af72725c sendfile: Only allow GET and HEAD requests. --- diff --git a/src/sendfile.c b/src/sendfile.c index e6f6786..81fb67a 100644 --- a/src/sendfile.c +++ b/src/sendfile.c @@ -271,13 +271,20 @@ int main(int argc, char **argv) simpleerror(1, 500, "Internal Error", "The server could not access its own data."); exit(1); } + if(!strcasecmp(argv[optind], "get")) { + ishead = 0; + } else if(!strcasecmp(argv[optind], "head")) { + ishead = 1; + } else { + simpleerror(1, 405, "Method not allowed", "The requested method is not defined for this resource."); + return(0); + } if(contype == NULL) contype = getmimetype(file, &sb); contype = ckctype(contype); checkcache(file, &sb); - ishead = !strcasecmp(argv[optind], "head"); if((hdr = getenv("REQ_RANGE")) != NULL) sendrange(fd, &sb, contype, hdr, ishead); else