git-config-set: Properly terminate strings with '\0'
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Mon, 21 Nov 2005 10:18:20 +0000 (11:18 +0100)
committerJunio C Hamano <junkio@cox.net>
Mon, 21 Nov 2005 22:04:22 +0000 (14:04 -0800)
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
config-set.c
config.c
index 5f654f7aff1cfa4cdbe5400d328363d4a91d490c..d938f967684f550515b54636a9a74ca00821a5c7 100644 (file)
@@ -38,6 +38,7 @@ static int get_value(const char* key_, const char* regex_)
        key = malloc(strlen(key_)+1);
        for (i = 0; key_[i]; i++)
                key[i] = tolower(key_[i]);
+       key[i] = 0;
 
        if (regex_) {
                if (regex_[0] == '!') {
index 5d237c862d4c7d0e3c62565849df7b87e4bf78a6..e78520ba07035fbd11b56fbf016ec4affe0dd9ac 100644 (file)
--- a/config.c
+++ b/config.c
@@ -432,6 +432,7 @@ int git_config_set_multivar(const char* key, const char* value,
                        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