* [PATCH 1/2] index-pack: allocate NUL byte at the buffer end
@ 2008-03-01 21:21 Martin Koegler
2008-03-01 21:21 ` [PATCH 2/2] unpack-objects: " Martin Koegler
2008-03-02 1:06 ` [PATCH 1/2] index-pack: " Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: Martin Koegler @ 2008-03-01 21:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Martin Koegler
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] unpack-objects: allocate NUL byte at the buffer end
2008-03-01 21:21 [PATCH 1/2] index-pack: allocate NUL byte at the buffer end Martin Koegler
@ 2008-03-01 21:21 ` Martin Koegler
2008-03-02 1:06 ` [PATCH 1/2] index-pack: " Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Martin Koegler @ 2008-03-01 21:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Martin Koegler
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
builtin-unpack-objects.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 9d2a854..1845abc 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -86,7 +86,8 @@ static void use(int bytes)
static void *get_data(unsigned long size)
{
z_stream stream;
- void *buf = xmalloc(size);
+ char *buf = xmalloc(size + 1);
+ buf[size] = 0;
memset(&stream, 0, sizeof(stream));
--
1.5.4.2.g4b5fd.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] index-pack: allocate NUL byte at the buffer end
2008-03-01 21:21 [PATCH 1/2] index-pack: allocate NUL byte at the buffer end Martin Koegler
2008-03-01 21:21 ` [PATCH 2/2] unpack-objects: " Martin Koegler
@ 2008-03-02 1:06 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2008-03-02 1:06 UTC (permalink / raw)
To: Martin Koegler; +Cc: git
Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> 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?
Perhaps because nobody other than index-pack itself accesses it as if it
is a NUL terminated buffer?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-03-02 1:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-01 21:21 [PATCH 1/2] index-pack: allocate NUL byte at the buffer end Martin Koegler
2008-03-01 21:21 ` [PATCH 2/2] unpack-objects: " Martin Koegler
2008-03-02 1:06 ` [PATCH 1/2] index-pack: " 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).