Thread (9 messages) flat view 9 messages, 2 authors, 2016-06-15

Re: [PATCH 1/2] drop length limitations on gecos-derived names and emails

From: Jeff King <hidden>
Date: 2016-06-15 22:53:50

Possibly related (same subject, not in this thread)

On Mon, May 14, 2012 at 05:02:25PM -0400, Jeff King wrote:
Ick, there is something very wrong with this patch. While testing a
completely unrelated bug, I noticed that it set my name to "Jeff
KingJeff KingJeff King". Which, while a wonderful ego massage, is
probably excessive.

I'm sure the problem is the switch to strbuf's appending semantics
rather than strlcpy's overwriting semantics. I thought we were careful
not to bother re-run the gecos code if we had already gotten a name, but
obviously that is not the case in some code paths. I'll investigate.
Ah, I see. The problem is here:
quoted hunk ↗ jump to hunk
--- a/config.c
+++ b/config.c
@@ -767,7 +767,7 @@ static int git_default_user_config(const char *var, const char *value)
 	if (!strcmp(var, "user.name")) {
 		if (!value)
 			return config_error_nonbool(var);
-		strlcpy(git_default_name, value, sizeof(git_default_name));
+		strbuf_addstr(&git_default_name, value);
 		user_ident_explicitly_given |= IDENT_NAME_GIVEN;
 		return 0;
 	}
@@ -775,7 +775,7 @@ static int git_default_user_config(const char *var, const char *value)
 	if (!strcmp(var, "user.email")) {
 		if (!value)
 			return config_error_nonbool(var);
-		strlcpy(git_default_email, value, sizeof(git_default_email));
+		strbuf_addstr(&git_default_email, value);
 		user_ident_explicitly_given |= IDENT_MAIL_GIVEN;
where we are not careful. The fix is trivial. However, while examining
fmt_ident, I notice there is another potential spot there that needs
further investigation (I think it may actually be unreachable code, but
I need to look closer).

I'll re-roll the series with the fixes after investigating fmt_ident.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help