diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index 15b326000..bf82e79a6 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -315,14 +315,16 @@ void HTTP_AddBuildFooter(http_request_t *request) { // add some more output safely, sending if necessary. // call with str == NULL to force send. int poststr(http_request_t *request, const char *str){ + int currentlen; + int addlen; if (NULL == str){ send(request->fd, request->reply, strlen(request->reply), 0); request->reply[0] = 0; return 0; } - int currentlen = strlen(request->reply); - int addlen = strlen(str); + currentlen = strlen(request->reply); + addlen = strlen(str); if (currentlen + addlen >= request->replymaxlen){ send(request->fd, request->reply, strlen(request->reply), 0); request->reply[0] = 0; @@ -341,11 +343,14 @@ int HTTP_ProcessPacket(http_request_t *request) { char tmpA[128]; char tmpB[64]; char tmpC[64]; + char *p; + char *headers; + char *protocol; //int bChanged = 0; char *urlStr = ""; char *recvbuf = request->received; - for (int i = 0; i < sizeof(methodNames)/sizeof(*methodNames); i++){ + for ( i = 0; i < sizeof(methodNames)/sizeof(*methodNames); i++){ if (http_startsWith(recvbuf, methodNames[i])){ urlStr = recvbuf + strlen(methodNames[i]) + 2; // skip method name plus space, plus slash request->method = i; @@ -371,7 +376,7 @@ int HTTP_ProcessPacket(http_request_t *request) { } // chop URL at space - char *p = strchr(urlStr, ' '); + p = strchr(urlStr, ' '); if (*p) { *p = '\0'; p++; // past space @@ -384,7 +389,7 @@ int HTTP_ProcessPacket(http_request_t *request) { request->url = urlStr; // protocol is next, termed by \r\n - char *protocol = p; + protocol = p; p = strchr(protocol, '\r'); if (*p) { *p = '\0'; @@ -397,7 +402,7 @@ int HTTP_ProcessPacket(http_request_t *request) { p++; // i.e. not received request->contentLength = -1; - char *headers = p; + headers = p; do { p = strchr(headers, '\r'); if (p != headers){ diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index e71133b56..727fbc011 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -136,10 +136,11 @@ static int http_rest_post(http_request_t *request){ return 0; } +// currently crashes the MCU - maybe stack overflow? static int http_rest_post_pins(http_request_t *request){ int i; int r; - char tmp[256]; + char tmp[64]; //https://github.com/zserge/jsmn/blob/master/example/simple.c jsmn_parser p;