git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] daemon: sanitize all directory separators

From
René Scharfe. <l.s.r@web.de>
Date
Mar 25, 2021, 16:21 UTC
Message-ID
<314451a4-ee8f-fb68-016f-66a4f3bea409@web.de>

When sanitizing client-supplied strings on Windows, also strip off backslashes, not just slashes.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 daemon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/daemon.c b/daemon.c
index 2ab7ea82eb..0561c19ee8 100644
--- a/daemon.c
+++ b/daemon.c
@@ -566,14 +566,14 @@ static void parse_host_and_port(char *hostport, char **host,

 /*
  * Sanitize a string from the client so that it's OK to be inserted into a
- * filesystem path. Specifically, we disallow slashes, runs of "..", and
- * trailing and leading dots, which means that the client cannot escape
- * our base path via ".." traversal.
+ * filesystem path. Specifically, we disallow directory separators, runs
+ * of "..", and trailing and leading dots, which means that the client
+ * cannot escape our base path via ".." traversal.
  */
 static void sanitize_client(struct strbuf *out, const char *in)
 {
 	for (; *in; in++) {
-		if (*in == '/')
+		if (is_dir_sep(*in))
 			continue;
 		if (*in == '.' && (!out->len || out->buf[out->len - 1] == '.'))
 			continue;
--
2.30.2
Next: Jeff King
Message 1 of 3 in “daemon: sanitize all directory separators”
  1. daemon: sanitize all directory separatorsRené Scharfe., Mar 25, 2021
  2. Jeff KingMar 26, 2021
  3. Johannes SchindelinMar 26, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.