Skip to content

Commit c0336ff

Browse files
rafaelgieschkegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 547e8b9 commit c0336ff

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ident.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
3434
*dst++ = toupper(*w->pw_name);
3535
memcpy(dst, w->pw_name + 1, nlen - 1);
3636
dst += nlen - 1;
37+
len += nlen;
3738
}
3839
}
3940
if (len < sz)

0 commit comments

Comments
 (0)