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

[PATCH] daemon: plug memory leak on overlong path

From
René Scharfe <l.s.r@web.de>
Date
Dec 18, 2021, 09:47 UTC
Message-ID
<5b151dc3-d4c7-29d3-71ed-a79033693d5d@web.de>

Release the strbuf containing the interpolated path after copying it to a stack buffer and before erroring out if it's too long.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon.c b/daemon.c
index 4a000ee4af..94a5b8a364 100644
--- a/daemon.c
+++ b/daemon.c
@@ -232,13 +232,13 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)

 		rlen = strlcpy(interp_path, expanded_path.buf,
 			       sizeof(interp_path));
+		strbuf_release(&expanded_path);
 		if (rlen >= sizeof(interp_path)) {
 			logerror("interpolated path too large: %s",
 				 interp_path);
 			return NULL;
 		}

-		strbuf_release(&expanded_path);
 		loginfo("Interpolated dir '%s'", interp_path);

 		dir = interp_path;
--
2.34.0
Next: Jeff King
Message 1 of 2 in “daemon: plug memory leak on overlong path”
  1. daemon: plug memory leak on overlong pathRené Scharfe, Dec 18, 2021
  2. Jeff KingDec 18, 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.