1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-05 12:56:11 +02:00

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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-09-24 17:07:16 -04:00 committed by Junio C Hamano
parent acd47eec99
commit c978610dc8

View File

@ -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;
}