[PATCH] Make git config fail on variables with no section, as documented

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Documentation/config.txt claims:

    Each variable must belong to some section, which means that there
    must be a section header before the first setting of a variable.

However, the parsing code did not enforce this.  This change makes it
a syntax error to defined a variable before the first section header.

Signed-off-by: Alex Vandiver <alex@xxxxxxxxx>
---
 config.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/config.c b/config.c
index 1b3823d..447ad00 100644
--- a/config.c
+++ b/config.c
@@ -248,6 +248,8 @@ static int git_parse_file(config_fn_t fn, void *data)
 		}
 		if (!isalpha(c))
 			break;
+		if (baselen == 0)
+			break;
 		var[baselen] = tolower(c);
 		if (get_value(fn, data, var, baselen+1) < 0)
 			break;
-- 
1.6.3.3.473.gb74fc4.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]