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>
This commit is contained in:
parent
356af64d84
commit
058412d097
@ -620,14 +620,16 @@ static char *get_short_ref(struct refinfo *ref)
|
|||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
const char *rule = ref_rev_parse_rules[j];
|
const char *rule = ref_rev_parse_rules[j];
|
||||||
unsigned char short_objectname[20];
|
unsigned char short_objectname[20];
|
||||||
|
char refname[PATH_MAX];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the short name is ambiguous, if it resolves
|
* the short name is ambiguous, if it resolves
|
||||||
* (with this previous rule) to a valid ref
|
* (with this previous rule) to a valid ref
|
||||||
* read_ref() returns 0 on success
|
* read_ref() returns 0 on success
|
||||||
*/
|
*/
|
||||||
if (!read_ref(mkpath(rule, short_name_len, short_name),
|
mksnpath(refname, sizeof(refname),
|
||||||
short_objectname))
|
rule, short_name_len, short_name);
|
||||||
|
if (!read_ref(refname, short_objectname))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user