From: Martin Koegler <mkoegler@auto.tuwien.ac.at>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Martin Koegler <mkoegler@auto.tuwien.ac.at>
Subject: [PATCH 1/2] index-pack: allocate NUL byte at the buffer end
Date: Sat, 1 Mar 2008 22:21:21 +0100 [thread overview]
Message-ID: <12044064822655-git-send-email-mkoegler@auto.tuwien.ac.at> (raw)
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
Other parts of git add a NUL to buffers as safty measure, so why not index-pack/
unpack-objects too?
index-pack.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 4bb333f..ff8e93d 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -213,7 +213,8 @@ static void bad_object(unsigned long offset, const char *format, ...)
static void *unpack_entry_data(unsigned long offset, unsigned long size)
{
z_stream stream;
- void *buf = xmalloc(size);
+ char *buf = xmalloc(size + 1);
+ buf[size] = 0;
memset(&stream, 0, sizeof(stream));
stream.next_out = buf;
--
1.5.4.2.g4b5fd.dirty
next reply other threads:[~2008-03-01 21:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 21:21 Martin Koegler [this message]
2008-03-01 21:21 ` [PATCH 2/2] unpack-objects: allocate NUL byte at the buffer end Martin Koegler
2008-03-02 1:06 ` [PATCH 1/2] index-pack: " 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=12044064822655-git-send-email-mkoegler@auto.tuwien.ac.at \
--to=mkoegler@auto.tuwien.ac.at \
--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).