summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-10-27 05:24:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-10-27 05:24:44 (GMT)
commit356af64d84076baaf90b0bf8adb7245771264e5a (patch)
tree008ecc6fdb6323d2bac3e09be6dce5b0de5f64cb /path.c
parent304d058370a9a797c38ec739c6d39fa45d9ed8e5 (diff)
parent9fa03c177ff826b439537072338af958fe01c257 (diff)
downloadgit-356af64d84076baaf90b0bf8adb7245771264e5a.zip
git-356af64d84076baaf90b0bf8adb7245771264e5a.tar.gz
git-356af64d84076baaf90b0bf8adb7245771264e5a.tar.bz2
Merge branch 'ar/maint-mksnpath' into HEAD
* ar/maint-mksnpath: 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
Diffstat (limited to 'path.c')
-rw-r--r--path.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/path.c b/path.c
index 76e8872..8b64878 100644
--- a/path.c
+++ b/path.c
@@ -32,6 +32,21 @@ static char *cleanup_path(char *path)
return path;
}
+char *mksnpath(char *buf, size_t n, const char *fmt, ...)
+{
+ va_list args;
+ unsigned len;
+
+ va_start(args, fmt);
+ len = vsnprintf(buf, n, fmt, args);
+ va_end(args);
+ if (len >= n) {
+ snprintf(buf, n, bad_path);
+ return buf;
+ }
+ return cleanup_path(buf);
+}
+
char *mkpath(const char *fmt, ...)
{
va_list args;