copy_gecos: fix not adding nlen to len when processing "&"

nlen has to be added to len when inserting (capitalized) pw_name as substitution for "&" in pw_gecos. Otherwise, pw_gecos will be truncated and data might be written beyond name+sz. Signed-off-by: Rafael Gieschke <rafael@gieschke.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rafael Gieschke committed May 16, 2011 at 22:08 UTC c0336ff27a9a4bf9db87d65c5dec1ebf7dd9f8c6
1 file changed +1
ident.c
+1
@@ -34,6 +34,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
34 *dst++ = toupper(*w->pw_name);
35 memcpy(dst, w->pw_name + 1, nlen - 1);
36 dst += nlen - 1;
37 + len += nlen;
38 }
39 }
40 if (len < sz)