summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd9314c)
raw | patch | inline | side by side (parent: dd9314c)
author | Jeff King <peff@peff.net> | |
Thu, 11 Feb 2010 21:07:06 +0000 (16:07 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 12 Feb 2010 06:11:03 +0000 (22:11 -0800) |
This gets rid of the fixed-size buffer and an unchecked
sprintf. That sprintf is actually OK as the only
variable-sized thing put in it is an abbreviated sha1, which
is bounded at 40 characters. However, the next patch will
change that to something unbounded.
Note that this function now returns an allocated buffer
instead of a static one; however, it doesn't matter as the
only caller exits immediately.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sprintf. That sprintf is actually OK as the only
variable-sized thing put in it is an abbreviated sha1, which
is bounded at 40 characters. However, the next patch will
change that to something unbounded.
Note that this function now returns an allocated buffer
instead of a static one; however, it doesn't matter as the
only caller exits immediately.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-revert.c | patch | blob | history |
diff --git a/builtin-revert.c b/builtin-revert.c
index 012c64644d6ec0f0519721aa35b55c79e439ec81..77e4f4eed37d5ab320b6df95b76f9af776ca2fbb 100644 (file)
--- a/builtin-revert.c
+++ b/builtin-revert.c
static char *help_msg(const unsigned char *sha1)
{
- static char helpbuf[1024];
+ struct strbuf helpbuf = STRBUF_INIT;
char *msg = getenv("GIT_CHERRY_PICK_HELP");
if (msg)
return msg;
- strcpy(helpbuf, " After resolving the conflicts,\n"
+ strbuf_addstr(&helpbuf, " After resolving the conflicts,\n"
"mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n"
"and commit the result.");
if (action == CHERRY_PICK) {
- sprintf(helpbuf + strlen(helpbuf),
+ strbuf_addf(&helpbuf,
" When committing, use the option '-c %s'\n"
"to retain authorship and message.",
find_unique_abbrev(sha1, DEFAULT_ABBREV));
}
- return helpbuf;
+ return strbuf_detach(&helpbuf, NULL);
}
static struct tree *empty_tree(void)