Skip to content

Commit

Permalink
copy_gecos: fix not adding nlen to len when processing "&"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael Gieschke authored and Junio C Hamano committed May 18, 2011
1 parent 547e8b9 commit c0336ff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c0336ff

Please sign in to comment.