Remove all leading dots in request paths
In addition to removing all double dots in the request paths, we should
remove all leading dots. After parsing request, the path is prepended
with another . thus leading to a .. at head of a crafted request.
@@ -332,7 +332,7 @@ date_to_epoch(const char *s)
}
static void
-remove_all_leading_dots(char *s)
+remove_all_leading_and_double_dots(char *s)
{
char *p = s;
@@ -544,7 +544,7 @@ decide_what_to_do(struct conn *c)
*c->query++ = '\0';
_shttpd_url_decode(c->uri, strlen(c->uri), c->uri, strlen(c->uri) + 1);
- remove_all_leading_dots(c->uri);
+ remove_all_leading_and_double_dots(c->uri);
root = c->ctx->options[OPT_ROOT];
if (strlen(c->uri) + strlen(root) >= sizeof(path)) {
