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>
Alex Riesen committed
Oct 26, 2008 at 23:08 UTC
058412d09748c90be996a70729b961adad084175
1 file changed
+4
-2
builtin-for-each-ref.c
+4
-2
@@ -620,14 +620,16 @@ static char *get_short_ref(struct refinfo *ref)
620
for (j = 0; j < i; j++) {
621
const char *rule = ref_rev_parse_rules[j];
622
unsigned char short_objectname[20];
623
+ char refname[PATH_MAX];
624
625
/*
626
* the short name is ambiguous, if it resolves
627
* (with this previous rule) to a valid ref
628
* read_ref() returns 0 on success
629
*/
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))
633
break;
634
}
635