From c0336ff27a9a4bf9db87d65c5dec1ebf7dd9f8c6 Mon Sep 17 00:00:00 2001 From: Rafael Gieschke Date: Mon, 16 May 2011 22:08:21 +0200 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- ident.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ident.c b/ident.c index 9e2438826d..4232084208 100644 --- a/ident.c +++ b/ident.c @@ -34,6 +34,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz) *dst++ = toupper(*w->pw_name); memcpy(dst, w->pw_name + 1, nlen - 1); dst += nlen - 1; + len += nlen; } } if (len < sz) -- 2.11.4.GIT