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

PATCH] bisect--helper: plug strvec leak in bisect_start()

From
René Scharfe <l.s.r@web.de>
Date
Oct 4, 2022, 16:06 UTC
Message-ID
<5c6a4c30-d454-51b6-ec57-9af036b9c4e0@web.de>

The strvec "argv" is used to build a command for run_command_v_opt(), but never freed. Use the "args" strvec of struct child_process and run_command() instead, which releases the allocated memory both on success and on error. We just also need to set the "git_cmd" bit directly.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/bisect--helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 501245fac9..9fe0c08479 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -765,11 +765,12 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
 		strbuf_read_file(&start_head, git_path_bisect_start(), 0);
 		strbuf_trim(&start_head);
 		if (!no_checkout) {
-			struct strvec argv = STRVEC_INIT;
+			struct child_process cmd = CHILD_PROCESS_INIT;

-			strvec_pushl(&argv, "checkout", start_head.buf,
+			cmd.git_cmd = 1;
+			strvec_pushl(&cmd.args, "checkout", start_head.buf,
 				     "--", NULL);
-			if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
+			if (run_command(&cmd)) {
 				res = error(_("checking out '%s' failed."
 						 " Try 'git bisect start "
 						 "<valid-branch>'."),
--
2.37.3
Next: Ævar Arnfjörð Bjarmason
Message 1 of 21 in “PATCH] bisect--helper: plug strvec leak in bisect_start()”
  1. René ScharfeOct 4, 2022
  2. Ævar Arnfjörð BjarmasonOct 5, 2022
  3. René ScharfeOct 5, 2022
  4. Junio C HamanoOct 5, 2022
  5. Ævar Arnfjörð BjarmasonOct 6, 2022
  6. Junio C HamanoOct 6, 2022
  7. bisect--helper: plug strvec leakRené Scharfe, Oct 7, 2022
  8. Junio C HamanoOct 7, 2022
  9. Jeff KingOct 11, 2022
  10. Junio C HamanoOct 11, 2022
  11. Ævar Arnfjörð BjarmasonOct 11, 2022
  12. Jeff KingOct 11, 2022
  13. Jeff KingOct 11, 2022
  14. Junio C HamanoOct 11, 2022
  15. Ævar Arnfjörð BjarmasonOct 11, 2022
  16. Junio C HamanoOct 11, 2022
  17. Jeff KingOct 14, 2022
  18. Junio C HamanoOct 14, 2022
  19. René ScharfeOct 15, 2022
  20. Jeff KingOct 15, 2022
  21. Junio C HamanoOct 5, 2022

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.