Skip to content

Commit

Permalink
test-path-utils: use xsnprintf in favor of strcpy
Browse files Browse the repository at this point in the history
This strcpy will never overflow because it's copying from
baked-in test data. But we would prefer to avoid strcpy
entirely, as it makes it harder to audit for real security
bugs.

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 Feb 8, 2016
1 parent e01c6b1 commit 7b11a18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test-path-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int test_function(struct test_data *data, char *(*func)(char *input),
if (!data[i].from)
to = func(NULL);
else {
strcpy(buffer, data[i].from);
xsnprintf(buffer, sizeof(buffer), "%s", data[i].from);
to = func(buffer);
}
if (!strcmp(to, data[i].to))
Expand Down

0 comments on commit 7b11a18

Please sign in to comment.