changes in v5: * set errno to ELOOP when MAXSYMLINKS is exceded. * revert to use MAXSYMLINKS instead of MAXDEPTH. * If the OS hasn't defined MAXSYMLINKS, use a fallback value of 32. Brandon Williams (4): real_path: resolve symlinks by hand real_path: convert real_path_internal to strbuf_realpath real_path: create real_pathdup real_path: have callers use real_pathdup and strbuf_realpath Johannes Sixt (1): real_path: canonicalize directory separators in root parts abspath.c | 231 +++++++++++++++++++++++++++++++++++++----------------- builtin/init-db.c | 6 +- cache.h | 3 + environment.c | 2 +- setup.c | 13 +-- sha1_file.c | 2 +- submodule.c | 2 +- transport.c | 2 +- worktree.c | 2 +- 9 files changed, 178 insertions(+), 85 deletions(-) --- interdiff with v4 diff --git a/abspath.c b/abspath.c index 3562d17bf..fce40fddc 100644 --- a/abspath.c +++ b/abspath.c @@ -62,7 +62,9 @@ static void get_root_part(struct strbuf *resolved, struct strbuf *remaining) } /* We allow "recursive" symbolic links. Only within reason, though. */ -#define MAXDEPTH 5 +#ifndef MAXSYMLINKS +#define MAXSYMLINKS 32 +#endif /* * Return the real path (i.e., absolute path, with symlinks resolved @@ -138,10 +140,12 @@ char *strbuf_realpath(struct strbuf *resolved, const char *path, ssize_t len; strbuf_reset(&symlink); - if (num_symlinks++ > MAXDEPTH) { + if (num_symlinks++ > MAXSYMLINKS) { + errno = ELOOP; + if (die_on_error) die("More than %d nested symlinks " - "on path '%s'", MAXDEPTH, path); + "on path '%s'", MAXSYMLINKS, path); else goto error_out; } -- 2.11.0.390.gc69c2f50cf-goog