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>
This commit is contained in:
parent
547e8b9205
commit
c0336ff27a
1
ident.c
1
ident.c
@ -34,6 +34,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
|
|||||||
*dst++ = toupper(*w->pw_name);
|
*dst++ = toupper(*w->pw_name);
|
||||||
memcpy(dst, w->pw_name + 1, nlen - 1);
|
memcpy(dst, w->pw_name + 1, nlen - 1);
|
||||||
dst += nlen - 1;
|
dst += nlen - 1;
|
||||||
|
len += nlen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len < sz)
|
if (len < sz)
|
||||||
|
Loading…
Reference in New Issue
Block a user