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.0.4~4^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9fa03c177ff826b439537072338af958fe01c257;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-apply.c b/builtin-apply.c index e9d49f133..50b623e54 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2850,8 +2850,8 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned unsigned int nr = getpid(); for (;;) { - const char *newpath; - newpath = mkpath("%s~%u", path, nr); + char newpath[PATH_MAX]; + mksnpath(newpath, sizeof(newpath), "%s~%u", path, nr); if (!try_create_file(newpath, mode, buf, size)) { if (!rename(newpath, path)) return;