Skip to content

Commit

Permalink
Fixed small bug in webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
CurlyMoo committed Feb 16, 2014
1 parent 32a71e1 commit 284991e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion libs/pilight/mongoose.c
Expand Up @@ -132,6 +132,7 @@ typedef struct stat file_stat_t;
#include <openssl/ssl.h>
#endif

#include "../../pilight.h"
#include "mongoose.h"

struct ll { struct ll *prev, *next; };
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions libs/pilight/webserver.c
Expand Up @@ -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 &&
Expand All @@ -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"))) {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 284991e

Please sign in to comment.