aboutsummaryrefslogtreecommitdiff
path: root/builtin-for-each-ref.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2008-10-26 23:08:52 +0100
committerJunio C Hamano <gitster@pobox.com>2008-10-26 22:25:09 -0700
commit058412d09748c90be996a70729b961adad084175 (patch)
tree2b47ac0423fde13e184d4384dfd82080fa738545 /builtin-for-each-ref.c
parent356af64d84076baaf90b0bf8adb7245771264e5a (diff)
downloadgit-058412d09748c90be996a70729b961adad084175.tar.gz
git-058412d09748c90be996a70729b961adad084175.tar.xz
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>
Diffstat (limited to 'builtin-for-each-ref.c')
-rw-r--r--builtin-for-each-ref.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index fa6c1ed75..e46b7adc9 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -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;
}