git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Off-by-one error in get_path_prefix(), found by Valgrind
@ 2006-06-07 17:01 Pavel Roskin
  2006-06-07 18:05 ` Rene Scharfe
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Roskin @ 2006-06-07 17:01 UTC (permalink / raw)
  To: git

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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-07 18:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-07 17:01 [PATCH] Off-by-one error in get_path_prefix(), found by Valgrind Pavel Roskin
2006-06-07 18:05 ` Rene Scharfe
2006-06-07 18:33   ` Pavel Roskin
2006-06-07 18:47     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).