git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated
@ 2011-04-10 20:54 Erik Faye-Lund
  2011-04-10 20:54 ` [PATCH v2 2/2] config: support values longer than 1023 bytes Erik Faye-Lund
  2011-04-10 20:57 ` [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Erik Faye-Lund @ 2011-04-10 20:54 UTC (permalink / raw)
  To: git; +Cc: jwa, drew.northup, peff

strbuf_init does not zero-terminate the initial buffer when hint is
non-zero. Fix this so strbuf_attach does not return garbage.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
 strbuf.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/strbuf.c b/strbuf.c
index 77444a9..09c43ae 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -30,8 +30,10 @@ void strbuf_init(struct strbuf *sb, size_t hint)
 {
 	sb->alloc = sb->len = 0;
 	sb->buf = strbuf_slopbuf;
-	if (hint)
+	if (hint) {
 		strbuf_grow(sb, hint);
+		sb->buf[0] = '\0';
+	}
 }
 
 void strbuf_release(struct strbuf *sb)
-- 
1.7.4.msysgit.0.916.ga2194

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-04-11 21:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-10 20:54 [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated Erik Faye-Lund
2011-04-10 20:54 ` [PATCH v2 2/2] config: support values longer than 1023 bytes Erik Faye-Lund
2011-04-10 20:58   ` Jeff King
2011-04-10 20:57 ` [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated Jeff King
2011-04-10 21:04   ` Erik Faye-Lund
2011-04-10 21:05     ` Jeff King
2011-04-11 21:49     ` 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).