test server post also take care about POST len termination
authorAndy Green <andy@warmcat.com>
Sun, 8 May 2016 09:10:24 +0000 (17:10 +0800)
committerAndy Green <andy@warmcat.com>
Sun, 8 May 2016 09:10:24 +0000 (17:10 +0800)
Signed-off-by: Andy Green <andy@warmcat.com>
test-server/test-server-http.c

index 32b36ba..215dc22 100644 (file)
@@ -407,6 +407,8 @@ int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
                lwsl_notice("LWS_CALLBACK_HTTP_BODY: len %d\n", (int)len);
                strncpy(pss->post_string, in, sizeof (pss->post_string) -1);
                pss->post_string[sizeof(pss->post_string) - 1] = '\0';
+               if (len < sizeof(pss->post_string) - 1)
+                       pss->post_string[len] = '\0';
                break;
 
        case LWS_CALLBACK_HTTP_BODY_COMPLETION: