From: Johannes Sixt <j.sixt@viscovery.net>
To: Pieter de Bie <pdebie@ai.rug.nl>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Suspicious code in builtin-fast-export.c
Date: Wed, 02 Jul 2008 11:04:28 +0200 [thread overview]
Message-ID: <486B449C.3050502@viscovery.net> (raw)
export_marks() has this code:
struct object_decoration *deco = idnums.hash;
...
for (i = 0; i < idnums.size; ++i) {
deco++;
if (deco && deco->base && deco->base->type == 1) {
...
}
}
I see that deco is off by one here at the end of the idnums.hash array
(and, btw, the check for 'deco &&' is always true). Indeed, this crashes
on Windows, and I can make it crash on Linux with this patch (which
overallocates a bit and writes junk into that space):
diff --git a/wrapper.c b/wrapper.c
index 4e04f76..658925e 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -72,7 +72,7 @@ void *xrealloc(void *ptr, size_t size)
void *xcalloc(size_t nmemb, size_t size)
{
- void *ret = calloc(nmemb, size);
+ void *ret = calloc(nmemb+1, size);
if (!ret && (!nmemb || !size))
ret = calloc(1, 1);
if (!ret) {
@@ -83,6 +83,7 @@ void *xcalloc(size_t nmemb, size_t size)
if (!ret)
die("Out of memory, calloc failed");
}
+ memset(ret+nmemb*size, 0xDE, size);
return ret;
}
--
1.5.6.64.gd77fe
reply other threads:[~2008-07-02 9:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=486B449C.3050502@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=git@vger.kernel.org \
--cc=pdebie@ai.rug.nl \
/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).