git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git@vger.kernel.org
Subject: [PATCH] Off-by-one error in get_path_prefix(), found by Valgrind
Date: Wed, 07 Jun 2006 13:01:40 -0400	[thread overview]
Message-ID: <20060607170140.13372.64613.stgit@dv.roinet.com> (raw)

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;

             reply	other threads:[~2006-06-07 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-07 17:01 Pavel Roskin [this message]
2006-06-07 18:05 ` [PATCH] Off-by-one error in get_path_prefix(), found by Valgrind Rene Scharfe
2006-06-07 18:33   ` Pavel Roskin
2006-06-07 18:47     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060607170140.13372.64613.stgit@dv.roinet.com \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).