X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fpsendfile.c;h=464440a0ae598c921f892664466cc64d9e051cd3;hb=595adb9922885c2a05bc6917ee8f8f02f496e618;hp=52ec9dc2204b6ef5ae4f86e7b18719eefc537697;hpb=a0ef58b1f5b0759e7bcd19a4d6e1eceae0b51edb;p=ashd.git diff --git a/src/psendfile.c b/src/psendfile.c index 52ec9dc..464440a 100644 --- a/src/psendfile.c +++ b/src/psendfile.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -227,7 +228,7 @@ static void serve(struct muth *muth, va_list args) sfile = NULL; contype = NULL; - out = mtstdopen(fd, 1, 60, "r+"); + out = mtstdopen(fd, 1, 60, "r+", NULL); if((file = getheader(req, "X-Ash-File")) == NULL) { flog(LOG_ERR, "psendfile: needs to be called with the X-Ash-File header"); @@ -238,7 +239,7 @@ static void serve(struct muth *muth, va_list args) simpleerror2(out, 404, "Not Found", "The requested URL has no corresponding resource."); goto out; } - if(((sfile = fopen(file, "r")) < 0) || fstat(fileno(sfile), &sb)) { + if(((sfile = fopen(file, "r")) == NULL) || fstat(fileno(sfile), &sb)) { flog(LOG_ERR, "psendfile: could not stat input file %s: %s", file, strerror(errno)); simpleerror2(out, 500, "Internal Error", "The server could not access its own data."); goto out; @@ -268,7 +269,8 @@ static void serve(struct muth *muth, va_list args) out: if(sfile != NULL) fclose(sfile); - free(contype); + if(contype != NULL) + free(contype); fclose(out); freehthead(req); }