uri processing reject paths not starting with slash
authorAndy Green <andy@warmcat.com>
Sat, 2 Apr 2016 00:03:48 +0000 (08:03 +0800)
committerAndy Green <andy@warmcat.com>
Sat, 2 Apr 2016 00:03:48 +0000 (08:03 +0800)
https://github.com/warmcat/libwebsockets/issues/481

Return 403 Forbidden if we don't end up with a uri path starting with /

Test server already did this, but this makes it built into the
library.

Signed-off-by: Andy Green <andy@warmcat.com>
lib/server.c

index 0b6e4c1f1baba8563fb0c56b46fc84bbb510a918..59e664f9374691eb7547e9fdb7d9ef96d6572c33 100644 (file)
@@ -243,6 +243,14 @@ lws_http_action(struct lws *wsi)
                        break;
                }
 
+       /* we insist on absolute paths */
+
+       if (uri_ptr[0] != '/') {
+               lws_return_http_status(wsi, HTTP_STATUS_FORBIDDEN, NULL);
+
+               goto bail_nuke_ah;
+       }
+
        /* HTTP header had a content length? */
 
        wsi->u.http.content_length = 0;