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

[PATCH] connect.c: fix leak in handle_ssh_variant

From
Jeff King <peff@peff.net>
Date
Apr 20, 2017, 20:21 UTC
Message-ID
<20170420202157.l2un35omz4vhffny@sigill.intra.peff.net>

When we see an error from split_cmdline(), we exit the function without freeing the copy of the command string we made.

This was sort-of introduced by 22e5ae5c8 (connect.c: handle errors from split_cmdline, 2017-04-10). The leak existed before that, but before that commit fixed the bug, we could never trigger this else clause in the first place.

Signed-off-by: Jeff King <peff@peff.net>
---
This was meant to be part of the original patch in:
  http://public-inbox.org/git/20170411003554.2tjnn65vfco376kj@sigill.intra.peff.net/

but I posted two versions in quick succession and Junio picked up the first one. :)

 connect.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/connect.c b/connect.c
index 568a35f75..cd21a1b6f 100644
--- a/connect.c
+++ b/connect.c
@@ -738,8 +738,10 @@ static void handle_ssh_variant(const char *ssh_command, int is_cmdline,
 			 * any longer.
 			 */
 			free(ssh_argv);
-		} else
+		} else {
+			free(p);
 			return;
+		}
 	}
 
 	if (!strcasecmp(variant, "plink") ||
-- 
2.13.0.rc0.363.g8726c260e
Message 1 of 1 in “connect.c: fix leak in handle_ssh_variant”
  1. connect.c: fix leak in handle_ssh_variantJeff King, Apr 20, 2017

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.