Skip to content

Commit

Permalink
Fix potentially dangerous uses of mkpath and git_path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Oct 27, 2008
1 parent 356af64 commit 058412d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin-for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,16 @@ static char *get_short_ref(struct refinfo *ref)
for (j = 0; j < i; j++) {
const char *rule = ref_rev_parse_rules[j];
unsigned char short_objectname[20];
char refname[PATH_MAX];

/*
* the short name is ambiguous, if it resolves
* (with this previous rule) to a valid ref
* read_ref() returns 0 on success
*/
if (!read_ref(mkpath(rule, short_name_len, short_name),
short_objectname))
mksnpath(refname, sizeof(refname),
rule, short_name_len, short_name);
if (!read_ref(refname, short_objectname))
break;
}

Expand Down

0 comments on commit 058412d

Please sign in to comment.