git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: [PATCH 1/3] fix memcpy of overlapping area
Date: Fri, 29 Jan 2010 05:28:44 -0500	[thread overview]
Message-ID: <20100129102844.GA6025@coredump.intra.peff.net> (raw)
In-Reply-To: <20100129102518.GA5875@coredump.intra.peff.net>

Caught by valgrind in t5500, but it is pretty obvious from
reading the code that this is shifting elements of an array
to the left, which needs memmove.

Signed-off-by: Jeff King <peff@peff.net>
---
This was introduced in f53514b (allow deepening of a shallow repository,
2006-10-30), released as part of v1.5.0. So probably 'maint'-worthy.

 commit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/commit.c b/commit.c
index 632061c..731191e 100644
--- a/commit.c
+++ b/commit.c
@@ -224,7 +224,7 @@ int unregister_shallow(const unsigned char *sha1)
 	if (pos < 0)
 		return -1;
 	if (pos + 1 < commit_graft_nr)
-		memcpy(commit_graft + pos, commit_graft + pos + 1,
+		memmove(commit_graft + pos, commit_graft + pos + 1,
 				sizeof(struct commit_graft *)
 				* (commit_graft_nr - pos - 1));
 	commit_graft_nr--;
-- 
1.7.0.rc0.41.g538720

  reply	other threads:[~2010-01-29 10:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28 14:52 [PATCH] rerere: fix too-short initialization Jeff King
2010-01-29 10:25 ` [PATCH 0/3] valgrind bug roundup Jeff King
2010-01-29 10:28   ` Jeff King [this message]
2010-01-29 10:31   ` [PATCH 2/3] fix off-by-one allocation error Jeff King
2010-01-29 10:37   ` [PATCH 3/3] add shebang line to git-mergetool--lib.sh Jeff King
2010-01-29 14:50     ` [PATCH] Do not install shell libraries executable Jonathan Nieder
2010-01-31  7:08       ` Junio C Hamano
2010-01-31  8:34         ` [PATCH v2] " Jonathan Nieder
2010-01-31 19:46           ` Junio C Hamano
2010-01-31 20:00             ` Jonathan Nieder
2010-01-31 20:05               ` Junio C Hamano
2010-01-31 21:00                 ` Jonathan Nieder
2010-01-31 21:08                   ` 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=20100129102844.GA6025@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).