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

Re: [PATCH v2] bisect--helper: plug strvec leak

From
Jeff King <peff@peff.net>
Date
Oct 11, 2022, 13:21 UTC
Message-ID
<Y0Vt4eAfUET1GEIp@coredump.intra.peff.net>
In-Reply-To
<221011.86k056q0l4.gmgdl@evledraar.gmail.com>
On Tue, Oct 11, 2022 at 09:29:01AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 22 quoted lines
> > But the code before this patch is safe only for strvec_pushl() call,
> > not run_command_v_opt() call, so we are not losing anything, I would
> > think.
> 
> Yes, and if we suppose a bug like this sneaking in one way or the other:
> 	
> 	diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> 	index 28ef7ec2a48..a7f9d43a6f1 100644
> 	--- a/builtin/bisect--helper.c
> 	+++ b/builtin/bisect--helper.c
> 	@@ -766,7 +766,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
> 	                strbuf_trim(&start_head);
> 	                if (!no_checkout) {
> 	                        const char *argv[] = { "checkout", start_head.buf,
> 	-                                              "--", NULL };
> 	+                                              "--" };
> 	 
> 	                        if (run_command_v_opt(argv, RUN_GIT_CMD)) {
> 	                                res = error(_("checking out '%s' failed."
> 
> I don't know a way to statically flag that, but we'll catch it with
> SANITIZE=address:

I'd expect we'd even catch it in a non-sanitizing build, since we'd likely feed garbage to exec (unless we get lucky and there's a NULL on the stack). I like catching bugs as early as possible, but I agree this kind is not likely to get very far (assuming there's test coverage).

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Jeff King
Message 12 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.