diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:16 -0800 |
commit | 1c16df23b19e8d37d896e68c92d8341d6e60b4dc (patch) | |
tree | d7e0ab46f28e103de500cee9d6edbb987bd40a96 /abspath.c | |
parent | 5918bdcf26030a2540ac25d5b8cbee82fad219fc (diff) | |
parent | 0b9864aa28ba08d7fb901afee1a75a15e4ad431b (diff) | |
download | git-1c16df23b19e8d37d896e68c92d8341d6e60b4dc.tar.gz |
Merge branch 'bw/realpath-wo-chdir'
The implementation of "real_path()" was to go there with chdir(2)
and call getcwd(3), but this obviously wouldn't be usable in a
threaded environment. Rewrite it to manually resolve relative
paths including symbolic links in path components.
* bw/realpath-wo-chdir:
real_path: set errno when max number of symlinks is exceeded
real_path: prevent redefinition of MAXSYMLINKS
Diffstat (limited to 'abspath.c')
-rw-r--r-- | abspath.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 MAXSYMLINKS 5 +#ifndef MAXSYMLINKS +#define MAXSYMLINKS 32 +#endif /* * Return the real path (i.e., absolute path, with symlinks resolved @@ -139,6 +141,8 @@ char *strbuf_realpath(struct strbuf *resolved, const char *path, strbuf_reset(&symlink); if (num_symlinks++ > MAXSYMLINKS) { + errno = ELOOP; + if (die_on_error) die("More than %d nested symlinks " "on path '%s'", MAXSYMLINKS, path); |