From f9255ddd4966787957cb8eb676155d99883d7955 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 7 Jan 2009 11:52:45 +0100 Subject: [PATCH] Fixed a couple of small bugs. --- lib/resp.c | 2 +- src/callcgi.c | 1 + src/htparser.c | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/resp.c b/lib/resp.c index b6c91ae..da354f9 100644 --- a/lib/resp.c +++ b/lib/resp.c @@ -76,7 +76,7 @@ void simpleerror(int fd, int code, char *msg, char *fmt, ...) out = fdopen(fd, "w"); fprintf(out, "HTTP/1.1 %i %s\r\n", code, msg); fprintf(out, "Content-Type: text/html\r\n"); - fprintf(out, "Content-Length: %i\r\n", buf.d); + fprintf(out, "Content-Length: %zi\r\n", buf.d); fprintf(out, "\r\n"); fwrite(buf.b, 1, buf.d, out); fclose(out); diff --git a/src/callcgi.c b/src/callcgi.c index c974fc3..8798c17 100644 --- a/src/callcgi.c +++ b/src/callcgi.c @@ -200,6 +200,7 @@ static void sendstatus(char **headers, FILE *out) **hp = 0; } else if(!strcasecmp(hp[0], "location")) { location = hp[1]; + hp += 2; } else { hp += 2; } diff --git a/src/htparser.c b/src/htparser.c index cec52dc..9f02ade 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -213,7 +213,7 @@ static off_t passdata(FILE *in, FILE *out, off_t max) char buf[8192]; total = 0; - while(!feof(in) && (total < max)) { + while(!feof(in) && ((max < 0) || (total < max))) { read = sizeof(buf); if(max >= 0) read = min(max - total, read); @@ -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")) { -- 2.11.0