From fc6d64cf7f1e970542cf6ebe5fe62c793600fc42 Mon Sep 17 00:00:00 2001 From: lxsang Date: Wed, 23 Nov 2016 23:02:10 +0100 Subject: [PATCH] fix cookie problem --- build/htdocs/.DS_Store | Bin 6148 -> 6148 bytes build/htdocs/scripts/.DS_Store | Bin 6148 -> 6148 bytes http_server.c | 6 +++--- plugin_manager.c | 10 +++++++--- plugins/plugin.c | 7 ++++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/build/htdocs/.DS_Store b/build/htdocs/.DS_Store index 5cbae99b96eedefbb6964b034b41510deac8ead3..35bd7b1fa74c1d10b4f4dcedffda7ee23eebe313 100755 GIT binary patch delta 67 zcmZoMXfc=|&e%S&P;8=}A|vy}0Ba!8qsYt7P|T3bP{feQP{2^KagHzhW_At%4#xJ4 W7r!%4<`>arWZ3K|a+rBy0}B9lZxZ1E delta 59 zcmV-B0L1@UY5r`QWn7|~22NV%tK*(=QT*?m8 KyP2EgCqDo+xDLbs delta 51 vcmZoMXfc?e&B4IH0LBvwMFg0D92j6^U=Y|?IE{T`gVbaL5thx|96$L1%DD*$ diff --git a/http_server.c b/http_server.c index ab00d08..dd3a9b6 100644 --- a/http_server.c +++ b/http_server.c @@ -137,11 +137,11 @@ void cat(int client, FILE *resource) { char buf[1024]; - fgets(buf, sizeof(buf), resource); - while (!feof(resource)) + //fgets(buf, sizeof(buf), resource); + while (fgets(buf, sizeof(buf), resource) != NULL) { send(client, buf, strlen(buf), 0); - fgets(buf, sizeof(buf), resource); + //fgets(buf, sizeof(buf), resource); } diff --git a/plugin_manager.c b/plugin_manager.c index 9873114..2ff8542 100644 --- a/plugin_manager.c +++ b/plugin_manager.c @@ -196,17 +196,21 @@ dictionary decode_cookie(const char* line) { char *token,*token1; char *cpstr = strdup(line); + trim(cpstr,' '); + trim(cpstr,'\n'); + trim(cpstr,'\r'); + //printf("FUCKIT %s\n",cpstr ); dictionary dic = NULL; while((token = strsep(&cpstr,";"))) { + trim(token,' '); token1 = strsep(&token,"="); if(token1) { if(dic == NULL) dic = dict(); - LOG("Found cookie : %s = %s\n",token1,token); - trim(token1,' '); - dput(dic,token1,token); + //LOG("Found cookie : %s = %s\n",token1,token); + dput(dic,token1,strdup(token)); } } //} diff --git a/plugins/plugin.c b/plugins/plugin.c index 100bcd0..e7cc3fc 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -200,12 +200,13 @@ int __f(int client, const char* file) LOG("Cannot read : %s\n", file); return 0; } - fgets(buf, sizeof(buf), ptr); - while(!feof(ptr)) + ; + while(fgets(buf, sizeof(buf), ptr) != NULL) { nbytes = send(client, buf, strlen(buf), 0); if(nbytes == -1) return 0; - fgets(buf, sizeof(buf), ptr); + //LOG("READ : %s\n", buf); + //fgets(buf, sizeof(buf), ptr); } fclose(ptr); return 1;