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

[PATCH] Off-by-one error in get_path_prefix(), found by Valgrind

From
PRPavel Roskin <proski@gnu.org>
Date
Jun 7, 2006, 17:01 UTC
Message-ID
<20060607170140.13372.64613.stgit@dv.roinet.com>
From: Pavel Roskin <proski@gnu.org>
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 builtin-tar-tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 5f740cf..05da1f2 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -166,8 +166,8 @@ static unsigned int ustar_header_chksum(
 static int get_path_prefix(const struct strbuf *path, int maxlen)
 {
 	int i = path->len;
-	if (i > maxlen)
-		i = maxlen;
+	if (i >= maxlen)
+		i = maxlen - 1;
 	while (i > 0 && path->buf[i] != '/')
 		i--;
 	return i;
Next: Rene Scharfe
Message 1 of 4 in “Off-by-one error in get_path_prefix(), found by Valgrind”
  1. Off-by-one error in get_path_prefix(), found by ValgrindPavel Roskin, Jun 7, 2006
  2. Rene ScharfeJun 7, 2006
  3. Pavel RoskinJun 7, 2006
  4. Junio C HamanoJun 7, 2006

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.