From 284991e0b866e8fd5c0177a83b8d9c553c79872e Mon Sep 17 00:00:00 2001 From: CurlyMoo Date: Sun, 16 Feb 2014 20:46:15 +0100 Subject: [PATCH] Fixed small bug in webserver --- libs/pilight/mongoose.c | 3 ++- libs/pilight/webserver.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/pilight/mongoose.c b/libs/pilight/mongoose.c index 5f2023fff..7cce87d77 100644 --- a/libs/pilight/mongoose.c +++ b/libs/pilight/mongoose.c @@ -132,6 +132,7 @@ typedef struct stat file_stat_t; #include #endif +#include "../../pilight.h" #include "mongoose.h" struct ll { struct ll *prev, *next; }; @@ -1094,7 +1095,7 @@ static void prepare_cgi_environment(struct connection *conn, } addenv(blk, "SERVER_ROOT=%s", opts[DOCUMENT_ROOT]); addenv(blk, "DOCUMENT_ROOT=%s", opts[DOCUMENT_ROOT]); - addenv(blk, "SERVER_SOFTWARE=%s/%s", "pilight", "3.0"); + addenv(blk, "SERVER_SOFTWARE=%s/%s", "pilight", VERSION); // Prepare the environment block addenv(blk, "%s", "GATEWAY_INTERFACE=CGI/1.1"); diff --git a/libs/pilight/webserver.c b/libs/pilight/webserver.c index 2afc449f0..08de1e272 100644 --- a/libs/pilight/webserver.c +++ b/libs/pilight/webserver.c @@ -526,7 +526,10 @@ static int webserver_request_handler(struct mg_connection *conn) { } } sfree((void *)&ext); - + + memset(buffer, '\0', 4096); + p = buffer; + if(access(request, F_OK) == 0) { stat(request, &st); if(webserver_cache && st.st_size <= MAX_CACHE_FILESIZE && @@ -537,9 +540,6 @@ static int webserver_request_handler(struct mg_connection *conn) { } else { goto filenotfound; } - - memset(buffer, '\0', 4096); - p = buffer; const char *cl = NULL; if((cl = mg_get_header(conn, "Content-Length"))) { @@ -612,8 +612,8 @@ static int webserver_request_handler(struct mg_connection *conn) { header[(pos-xpos)] = '\0'; /* Extract content info from PHP output */ - memmove(&output[xpos], &output[pos+3], olen-(pos+3)); - olen-=((pos+3)-xpos); + memmove(&output[xpos], &output[pos+3], olen-(pos+2)); + olen-=((pos+2)-xpos); /* Retrieve the PHP content type */ char ite[pos-xpos];