Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
fetch: use heap buffer to format reflog
author
Jeff King
<peff@peff.net>
Tue, 28 Mar 2017 19:46:26 +0000
(15:46 -0400)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 30 Mar 2017 21:59:50 +0000
(14:59 -0700)
Part of the reflog content comes from the environment, which
can be much larger than our fixed buffer. Let's use a heap
buffer so we avoid truncating it.
Signed-off-by: Jeff King <peff@peff.net>
builtin/fetch.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b0ceab9
)
diff --git
a/builtin/fetch.c
b/builtin/fetch.c
index b5ad09d0460cc7a51f35a56a4304e6a1fb26d26e..4ef7a08afc79a02dfb49a54065544666d1f6b6da 100644
(file)
--- a/
builtin/fetch.c
+++ b/
builtin/fetch.c
@@
-421,7
+421,7
@@
static int s_update_ref(const char *action,
struct ref *ref,
int check_old)
{
struct ref *ref,
int check_old)
{
- char
msg[1024]
;
+ char
*msg
;
char *rla = getenv("GIT_REFLOG_ACTION");
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
char *rla = getenv("GIT_REFLOG_ACTION");
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
@@
-431,7
+431,7
@@
static int s_update_ref(const char *action,
return 0;
if (!rla)
rla = default_rla.buf;
return 0;
if (!rla)
rla = default_rla.buf;
-
snprintf(msg, sizeof(msg),
"%s: %s", rla, action);
+
msg = xstrfmt(
"%s: %s", rla, action);
transaction = ref_transaction_begin(&err);
if (!transaction ||
transaction = ref_transaction_begin(&err);
if (!transaction ||
@@
-449,11
+449,13
@@
static int s_update_ref(const char *action,
ref_transaction_free(transaction);
strbuf_release(&err);
ref_transaction_free(transaction);
strbuf_release(&err);
+ free(msg);
return 0;
fail:
ref_transaction_free(transaction);
error("%s", err.buf);
strbuf_release(&err);
return 0;
fail:
ref_transaction_free(transaction);
error("%s", err.buf);
strbuf_release(&err);
+ free(msg);
return df_conflict ? STORE_REF_ERROR_DF_CONFLICT
: STORE_REF_ERROR_OTHER;
}
return df_conflict ? STORE_REF_ERROR_DF_CONFLICT
: STORE_REF_ERROR_OTHER;
}