]> git.ipfire.org Git - thirdparty/git.git/commit - run-command.c
path.c: make get_pathname() call sites return const char *
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 30 Nov 2014 08:24:27 +0000 (15:24 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Dec 2014 19:00:10 +0000 (11:00 -0800)
commitdcf692625ac569fefbe52269061230f4fde10e47
treea56beac7a3de4c6bd8557288f802fc28738b52a4
parent4ef9caf5431dbbd23f240a25b69a989aeb9840a4
path.c: make get_pathname() call sites return const char *

Before the previous commit, get_pathname returns an array of PATH_MAX
length. Even if git_path() and similar functions does not use the
whole array, git_path() caller can, in theory.

After the commit, get_pathname() may return a buffer that has just
enough room for the returned string and git_path() caller should never
write beyond that.

Make git_path(), mkpath() and git_path_submodule() return a const
buffer to make sure callers do not write in it at all.

This could have been part of the previous commit, but the "const"
conversion is too much distraction from the core changes in path.c.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 files changed:
builtin/checkout.c
builtin/clone.c
builtin/fetch.c
builtin/fsck.c
builtin/receive-pack.c
builtin/remote.c
builtin/repack.c
cache.h
fast-import.c
notes-merge.c
path.c
refs.c
run-command.c
run-command.h
sha1_file.c