git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] avoid off-by-one error in run_upload_archive

From
JVJochen Voss <voss@seehuhn.de>
Date
Jun 28, 2008, 16:04 UTC
Message-ID
<20080628160424.GA27915@seehuhn.de>

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>
---
 builtin-upload-archive.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index 48ae09e..371400d 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -30,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
 	if (argc != 2)
 		usage(upload_archive_usage);
 
-	if (strlen(argv[1]) > sizeof(buf))
+	if (strlen(argv[1]) + 1 > sizeof(buf))
 		die("insanely long repository name");
 
 	strcpy(buf, argv[1]); /* enter-repo smudges its argument */
-- 
1.5.3.7
Message 1 of 1 in “avoid off-by-one error in run_upload_archive”
  1. avoid off-by-one error in run_upload_archiveJochen Voss, Jun 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.