# [PATCH] commit.c: guard config parser from value=NULL

2 messages from 2008-02-09 to 2008-02-10. Participants: Govind Salinas, Junio C Hamano.
Thread: https://gitlist.dev/t/11996

## Govind Salinas, 2008-02-09 20:16

Subject: [PATCH] commit.c: guard config parser from value=NULL
Message-ID: <5d46db230802091216h40f88f06r20ebb84de6717af6@mail.gmail.com>
URL: https://gitlist.dev/e/5d46db230802091216h40f88f06r20ebb84de6717af6%40mail.gmail.com

```
Signed-off-by: Govind Salinas <blix@sophiasuchtig.com>
---
 config.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/config.c b/config.c
index 498259e..8247e88 100644
--- a/config.c
+++ b/config.c
@@ -407,12 +407,12 @@ int git_default_config(const char *var, const char *value)
 		return 0;
 	}

-	if (!strcmp(var, "user.name")) {
+	if (value && !strcmp(var, "user.name")) {
 		strlcpy(git_default_name, value, sizeof(git_default_name));
 		return 0;
 	}

-	if (!strcmp(var, "user.email")) {
+	if (value && !strcmp(var, "user.email")) {
 		strlcpy(git_default_email, value, sizeof(git_default_email));
 		return 0;
 	}
-- 
1.5.4.36.g9af61

```

## Junio C Hamano, 2008-02-10 02:57

Subject: Re: [PATCH] commit.c: guard config parser from value=NULL
Message-ID: <7vir0x5xi0.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vir0x5xi0.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <5d46db230802091216h40f88f06r20ebb84de6717af6@mail.gmail.com>

```
"Govind Salinas" <govind@sophiasuchtig.com> writes:

> -	if (!strcmp(var, "user.name")) {
> +	if (value && !strcmp(var, "user.name")) {
>  		strlcpy(git_default_name, value, sizeof(git_default_name));
>  		return 0;
>  	}

This is wrong, isn't it?  When somebody says

	[user]
        	name

we should not silently ignore it, but instead say "user.name is
not a bool!" and error out.

The same comment applies to all other

	if (value && !strcmp(var, "<varname>"))

conversions.

```
