From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: jwa@urbancode.com, drew.northup@maine.edu, peff@peff.net
Subject: [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated
Date: Sun, 10 Apr 2011 22:54:17 +0200 [thread overview]
Message-ID: <1302468858-7376-1-git-send-email-kusmabite@gmail.com> (raw)
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
next reply other threads:[~2011-04-10 20:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-10 20:54 Erik Faye-Lund [this message]
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
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302468858-7376-1-git-send-email-kusmabite@gmail.com \
--to=kusmabite@gmail.com \
--cc=drew.northup@maine.edu \
--cc=git@vger.kernel.org \
--cc=jwa@urbancode.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).