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

Re: [PATCH] config: don't segfault when given --path with a missing value

From
Jeff King <peff@peff.net>
Date
Nov 15, 2012, 16:18 UTC
Message-ID
<20121115161758.GC6157@sigill.intra.peff.net>
In-Reply-To
<20121115161149.GB6157@sigill.intra.peff.net>
On Thu, Nov 15, 2012 at 08:11:50AM -0800, Jeff King wrote:
Show 9 quoted lines
> Hmm, actually, we should probably propagate the error (I was thinking
> for some reason this was in the listing code, but it is really about
> getting a specific variable, and that variable does not have a sane
> format. We'll already have printed the non-bool error, so we should
> probably die. So more like:
> 
>   if (git_config_pathname(&vptr, key_, value_) < 0)
>           return -1;
>   must_free_vptr = 1;

You may want to squash in this test, which triggers your original problem, but also demonstrates the use of uninitialized memory (although you need to run under valgrind or similar to reliably notice it).

diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index e127f35..7c4c372 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
 	test_cmp expect result
 '
 
+test_expect_success 'get --path barfs on boolean variable' '
+	echo "[path]bool" >.git/config &&
+	test_must_fail git config --get --path path.bool
+'
+
 cat > expect << EOF
 [quote]
 	leading = " test"

-Peff
Previous: Jeff KingNext: Carlos Martín Nieto
Message 4 of 6 in “config: don't segfault when given --path with a missing value”
  1. config: don't segfault when given --path with a missing valueCarlos Martín Nieto, Nov 14, 2012
  2. Jeff KingNov 15, 2012
  3. Jeff KingNov 15, 2012
  4. Jeff KingNov 15, 2012
  5. config: don't segfault when given --path with a missing valueCarlos Martín Nieto, Nov 15, 2012
  6. Jeff KingNov 15, 2012

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.