diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-10-26 22:24:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-10-26 22:24:44 -0700 |
commit | 356af64d84076baaf90b0bf8adb7245771264e5a (patch) | |
tree | 008ecc6fdb6323d2bac3e09be6dce5b0de5f64cb /path.c | |
parent | 304d058370a9a797c38ec739c6d39fa45d9ed8e5 (diff) | |
parent | 9fa03c177ff826b439537072338af958fe01c257 (diff) | |
download | git-356af64d84076baaf90b0bf8adb7245771264e5a.tar.gz |
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.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; |