From: Alex Riesen Date: Sun, 26 Oct 2008 22:08:52 +0000 (+0100) Subject: Fix potentially dangerous uses of mkpath and git_path X-Git-Tag: v1.6.1-rc1~84^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=058412d09748c90be996a70729b961adad084175;p=git.git 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 Signed-off-by: Junio C Hamano --- 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; }