summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 17:07:40 -0400
committerJunio C Hamano <gitster@pobox.com>2015-10-05 11:08:04 -0700
commitbd22d4ffbc10052fef1a6c52aec066ee64236340 (patch)
treed19c7f990f169af3d0b34a46bfe20c46bd1c1adf /transport.c
parent6c31c22cebe9f0b117fd93ee7792d88e82aaa61e (diff)
downloadgit-bd22d4ffbc10052fef1a6c52aec066ee64236340.tar.gz
transport: use strbufs for status table "quickref" strings
We generate range strings like "1234abcd...5678efab" for use in the the fetch and push status tables. We use fixed-size buffers along with strcat to do so. These aren't buggy, as our manual size computation is correct, but there's nothing checking that this is so. Let's switch them to strbufs instead, which are obviously correct, and make it easier to audit the code base for problematic calls to strcat(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/transport.c b/transport.c
index 2d51348f3f..3b47d493d1 100644
--- a/transport.c
+++ b/transport.c
@@ -654,23 +654,24 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
"[new branch]"),
ref, ref->peer_ref, NULL, porcelain);
else {
- char quickref[84];
+ struct strbuf quickref = STRBUF_INIT;
char type;
const char *msg;
- strcpy(quickref, status_abbrev(ref->old_sha1));
+ strbuf_addstr(&quickref, status_abbrev(ref->old_sha1));
if (ref->forced_update) {
- strcat(quickref, "...");
+ strbuf_addstr(&quickref, "...");
type = '+';
msg = "forced update";
} else {
- strcat(quickref, "..");
+ strbuf_addstr(&quickref, "..");
type = ' ';
msg = NULL;
}
- strcat(quickref, status_abbrev(ref->new_sha1));
+ strbuf_addstr(&quickref, status_abbrev(ref->new_sha1));
- print_ref_status(type, quickref, ref, ref->peer_ref, msg, porcelain);
+ print_ref_status(type, quickref.buf, ref, ref->peer_ref, msg, porcelain);
+ strbuf_release(&quickref);
}
}