summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b09b868)
raw | patch | inline | side by side (parent: b09b868)
author | Stephen Boyd <bebarino@gmail.com> | |
Tue, 31 Mar 2009 23:24:38 +0000 (16:24 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 1 Apr 2009 18:05:31 +0000 (11:05 -0700) |
If the subject line is '...' the strbuf will be accessed before the
first dot is added; potentially changing the strbuf passed into the
function or accessing sb->buf[-1] if it was originally empty.
Reported-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
first dot is added; potentially changing the strbuf passed into the
function or accessing sb->buf[-1] if it was originally empty.
Reported-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c | patch | blob | history |
diff --git a/pretty.c b/pretty.c
index c57cef47c93912a709fc67fe98cdcff15ed34dc6..a0ef356558f4cdb148010f1b47dbd3fcc363d8ba 100644 (file)
--- a/pretty.c
+++ b/pretty.c
static void format_sanitized_subject(struct strbuf *sb, const char *msg)
{
size_t trimlen;
+ size_t start_len = sb->len;
int space = 2;
for (; *msg && *msg != '\n'; msg++) {
/* trim any trailing '.' or '-' characters */
trimlen = 0;
- while (sb->buf[sb->len - 1 - trimlen] == '.'
- || sb->buf[sb->len - 1 - trimlen] == '-')
+ while (sb->len - trimlen > start_len &&
+ (sb->buf[sb->len - 1 - trimlen] == '.'
+ || sb->buf[sb->len - 1 - trimlen] == '-'))
trimlen++;
strbuf_remove(sb, sb->len - trimlen, trimlen);
}