diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-11-05 11:35:53 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-11-05 11:35:53 -0800 |
commit | a1a846a19e854a3b3baff8f55c039846880a2635 (patch) | |
tree | 0d6aebb3626cbc4204a1ec455e3b2105b4733062 /sha1_name.c | |
parent | d95f91d9e48a88a39ac2de5bfddd9d33fd36435d (diff) | |
parent | 98b35e2c749614446b916230148d66857e8a09f3 (diff) | |
download | git-a1a846a19e854a3b3baff8f55c039846880a2635.tar.gz |
Merge branch 'ar/mksnpath'
* ar/mksnpath:
Use git_pathdup instead of xstrdup(git_path(...))
git_pathdup: returns xstrdup-ed copy of the formatted path
Fix potentially dangerous use of git_path in ref.c
Add git_snpath: a .git path formatting routine with output buffer
Fix potentially dangerous uses of mkpath and git_path
Fix potentially dangerous uses of mkpath and git_path
Fix mkpath abuse in dwim_ref and dwim_log of sha1_name.c
Add mksnpath which allows you to specify the output buffer
Conflicts:
builtin-revert.c
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c index 41b680915d..159c2ab84f 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -245,11 +245,13 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref) *ref = NULL; for (p = ref_rev_parse_rules; *p; p++) { + char fullref[PATH_MAX]; unsigned char sha1_from_ref[20]; unsigned char *this_result; this_result = refs_found ? sha1_from_ref : sha1; - r = resolve_ref(mkpath(*p, len, str), this_result, 1, NULL); + mksnpath(fullref, sizeof(fullref), *p, len, str); + r = resolve_ref(fullref, this_result, 1, NULL); if (r) { if (!refs_found++) *ref = xstrdup(r); @@ -272,7 +274,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log) char path[PATH_MAX]; const char *ref, *it; - strcpy(path, mkpath(*p, len, str)); + mksnpath(path, sizeof(path), *p, len, str); ref = resolve_ref(path, hash, 1, NULL); if (!ref) continue; |