Skip to content

Commit 058412d

Browse files
raalkmlgitster
authored andcommitted
Fix potentially dangerous uses of mkpath and git_path
Replace them with mksnpath/git_snpath and a local buffer for the resulting string. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 356af64 commit 058412d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

builtin-for-each-ref.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,16 @@ static char *get_short_ref(struct refinfo *ref)
620620
for (j = 0; j < i; j++) {
621621
const char *rule = ref_rev_parse_rules[j];
622622
unsigned char short_objectname[20];
623+
char refname[PATH_MAX];
623624

624625
/*
625626
* the short name is ambiguous, if it resolves
626627
* (with this previous rule) to a valid ref
627628
* read_ref() returns 0 on success
628629
*/
629-
if (!read_ref(mkpath(rule, short_name_len, short_name),
630-
short_objectname))
630+
mksnpath(refname, sizeof(refname),
631+
rule, short_name_len, short_name);
632+
if (!read_ref(refname, short_objectname))
631633
break;
632634
}
633635

0 commit comments

Comments
 (0)