diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2008-10-26 23:08:52 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-10-26 22:25:09 -0700 |
commit | 058412d09748c90be996a70729b961adad084175 (patch) | |
tree | 2b47ac0423fde13e184d4384dfd82080fa738545 /builtin-for-each-ref.c | |
parent | 356af64d84076baaf90b0bf8adb7245771264e5a (diff) | |
download | git-058412d09748c90be996a70729b961adad084175.tar.gz |
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.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index fa6c1ed752..e46b7adc97 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; } |