fetch: use heap buffer to format reflog
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>
Jeff King committed
Mar 28, 2017 at 15:46 UTC
1412f762e0363c126ea011682b61a8c9d7d7456f
1 file changed
+4
-2
builtin/fetch.c
+4
-2
@@ -421,7 +421,7 @@ static int s_update_ref(const char *action,
421
struct ref *ref,
422
int check_old)
423
{
424
- char msg[1024];
424
+ char *msg;
425
char *rla = getenv("GIT_REFLOG_ACTION");
426
struct ref_transaction *transaction;
427
struct strbuf err = STRBUF_INIT;
@@ -431,7 +431,7 @@ static int s_update_ref(const char *action,
431
return 0;
432
if (!rla)
433
rla = default_rla.buf;
434
- snprintf(msg, sizeof(msg), "%s: %s", rla, action);
434
+ msg = xstrfmt("%s: %s", rla, action);
435
436
transaction = ref_transaction_begin(&err);
437
if (!transaction ||
@@ -449,11 +449,13 @@ static int s_update_ref(const char *action,
449
450
ref_transaction_free(transaction);
451
strbuf_release(&err);
452
+ free(msg);
453
return 0;
454
fail:
455
ref_transaction_free(transaction);
456
error("%s", err.buf);
457
strbuf_release(&err);
458
+ free(msg);
459
return df_conflict ? STORE_REF_ERROR_DF_CONFLICT
460
: STORE_REF_ERROR_OTHER;
461
}