threads / patch / 2626

patchgit-config-set: Properly terminate strings with '\0'

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

## tl;dr

One message between Nov 21, 2005 and Nov 21, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Johannes Schindelin· Nov 21, 2005, 10:18 UTC · lore

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

Show changes to 2 files +2 −0

config-set.c, config.c

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

← back to recent threads