Skip to content

Commit

Permalink
mailmap: replace strcpy with xstrdup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Sep 25, 2015
1 parent acd47ee commit c978610
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mailmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c978610

Please sign in to comment.