daemon: sanitize all directory separators

When sanitizing client-supplied strings on Windows, also strip off backslashes, not just slashes. Signed-off-by: René Scharfe <l.s.r@web.de> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Mar 25, 2021 at 17:21 UTC 9a7f1ce8b78dae09cf4510a98bd6b81d0d478772
1 file changed +4 -4
daemon.c
+4 -4
@@ -566,14 +566,14 @@ static void parse_host_and_port(char *hostport, char **host,
566
567 /*
568 * Sanitize a string from the client so that it's OK to be inserted into a
569 - * filesystem path. Specifically, we disallow slashes, runs of "..", and
570 - * trailing and leading dots, which means that the client cannot escape
571 - * our base path via ".." traversal.
569 + * filesystem path. Specifically, we disallow directory separators, runs
570 + * of "..", and trailing and leading dots, which means that the client
571 + * cannot escape our base path via ".." traversal.
572 */
573 static void sanitize_client(struct strbuf *out, const char *in)
574 {
575 for (; *in; in++) {
576 - if (*in == '/')
576 + if (is_dir_sep(*in))
577 continue;
578 if (*in == '.' && (!out->len || out->buf[out->len - 1] == '.'))
579 continue;