From c978610dc841efe300bf4d1ee61b24d78b13c4f4 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Sep 2015 17:07:16 -0400 Subject: mailmap: replace strcpy with xstrdup We want to make a copy of a string without any leading whitespace. To do so, we allocate a buffer large enough to hold the original, skip past the whitespace, then copy that. It's much simpler to just allocate after we've skipped, in which case we can just copy the remainder of the string, leaving no question of whether "len" is large enough. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- mailmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mailmap.c') diff --git a/mailmap.c b/mailmap.c index 9e9589730f..f4a0f1cf27 100644 --- a/mailmap.c +++ b/mailmap.c @@ -162,11 +162,10 @@ static void read_mailmap_line(struct string_list *map, char *buffer, char *cp; free(*repo_abbrev); - *repo_abbrev = xmalloc(len); for (cp = buffer + abblen; isspace(*cp); cp++) ; /* nothing */ - strcpy(*repo_abbrev, cp); + *repo_abbrev = xstrdup(cp); } return; } -- cgit v1.2.3