test-path-utils: use xsnprintf in favor of strcpy
authorJeff King <peff@peff.net>
Mon, 8 Feb 2016 22:21:55 +0000 (17:21 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Feb 2016 22:42:32 +0000 (14:42 -0800)
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>
test-path-utils.c
index c3adcd87b8caa2028785483bbc01d85fd0f7a9d6..6232dfe661a53d1eaf17ead5133da5792ae2413f 100644 (file)
@@ -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))