X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fhtparser.c;h=9f02adea02fe44c7463fc22d9709229fc7f5ea87;hb=f9255ddd4966787957cb8eb676155d99883d7955;hp=68a330082fd8c796bb677804b2177544d5cebf0b;hpb=5fc1bf9ffd24123e1fafbfc8b58c4338521ec0e6;p=ashd.git diff --git a/src/htparser.c b/src/htparser.c index 68a3300..9f02ade 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -213,10 +213,10 @@ static off_t passdata(FILE *in, FILE *out, off_t max) char buf[8192]; total = 0; - while(!feof(in)) { + while(!feof(in) && ((max < 0) || (total < max))) { read = sizeof(buf); if(max >= 0) - read = max(max - total, read); + read = min(max - total, read); read = fread(buf, 1, read, in); if(ferror(in)) return(-1); @@ -236,7 +236,7 @@ static int passchunks(FILE *in, FILE *out) read = fread(buf, 1, sizeof(buf), in); if(ferror(in)) return(-1); - fprintf(out, "%x\r\n", read); + fprintf(out, "%zx\r\n", read); if(fwrite(buf, 1, read, out) != read) return(-1); fprintf(out, "\r\n"); @@ -305,7 +305,8 @@ static void serve(struct muth *muth, va_list args) /* Make sure to send EOF */ shutdown(pfds[1], SHUT_WR); - resp = parseresp(out); + if((resp = parseresp(out)) == NULL) + break; replstr(&resp->ver, req->ver); if(!strcmp(req->ver, "HTTP/1.0")) {