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

[PATCH] git-config-set: Properly terminate strings with '\0'

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 21, 2005, 10:18 UTC
Message-ID
<Pine.LNX.4.63.0511211117530.13161@wbgn013.biozentrum.uni-wuerzburg.de>

When a lowercase version of the key was generated, it was not terminated. Strangely enough, it worked on Linux and macosx anyway. Just cygwin barfed.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 config-set.c |    1 +
 config.c     |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

applies-to: f7083280a1a5b84bbf5c6e74177e21807d5ee56b 6da767ad3f7ca0c1e86e7ec42765fcb01417d695

diff --git a/config-set.c b/config-set.c
index 5f654f7..d938f96 100644
--- a/config-set.c
+++ b/config-set.c
@@ -38,6 +38,7 @@ static int get_value(const char* key_, c
 	key = malloc(strlen(key_)+1);
 	for (i = 0; key_[i]; i++)
 		key[i] = tolower(key_[i]);
+	key[i] = 0;
 
 	if (regex_) {
 		if (regex_[0] == '!') {
diff --git a/config.c b/config.c
index 38c0edd..357c1ca 100644
--- a/config.c
+++ b/config.c
@@ -433,6 +433,7 @@ int git_config_set_multivar(const char* 
 			return 1;
 		} else
 			store.key[i] = tolower(key[i]);
+	store.key[i] = 0;
 
 	/*
 	 * The lock_file serves a purpose in addition to locking: the new
---
0.99.9.GIT
Message 1 of 1 in “git-config-set: Properly terminate strings with '\0'”
  1. git-config-set: Properly terminate strings with '\0'Johannes Schindelin, Nov 21, 2005

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.