@matheusbsbs / matheus-bagliano / commits / 74d817cf8c
Fork 0

avoid off-by-one error in run_upload_archive

Make sure that buf has enough space to store the trailing \0 of the command line argument, too. Signed-off-by: Jochen Voss <voss@seehuhn.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jochen Voss committed Jun 28, 2008 at 17:04 UTC 74d817cf8cf68104564cf6c93c1361f66dad1901
1 file changed +1 -1
builtin-upload-archive.c
+1 -1
@@ -30,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
30 if (argc != 2)
31 usage(upload_archive_usage);
32
33 - if (strlen(argv[1]) > sizeof(buf))
33 + if (strlen(argv[1]) + 1 > sizeof(buf))
34 die("insanely long repository name");
35
36 strcpy(buf, argv[1]); /* enter-repo smudges its argument */