Skip to content

Commit 0e71bc3

Browse files
trastgitster
authored andcommitted
check_aliased_update: strcpy() instead of strcat() to copy
da3efdb (receive-pack: detect aliased updates which can occur with symrefs, 2010-04-19) introduced two strcat() into uninitialized strings. The intent was clearly make a copy of the static buffer used by find_unique_abbrev(), so use strcpy() instead. Signed-off-by: Thomas Rast <[email protected]> Reported-by: Ævar Arnfjörð Bjarmason <[email protected]> Tested-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da3efdb commit 0e71bc3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin-receive-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
515515
dst_cmd->skip_update = 1;
516516

517517
strcpy(cmd_oldh, find_unique_abbrev(cmd->old_sha1, DEFAULT_ABBREV));
518-
strcat(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
518+
strcpy(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
519519
strcpy(dst_oldh, find_unique_abbrev(dst_cmd->old_sha1, DEFAULT_ABBREV));
520-
strcat(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
520+
strcpy(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
521521
rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
522522
" its target '%s' (%s..%s)",
523523
cmd->ref_name, cmd_oldh, cmd_newh,

0 commit comments

Comments
 (0)