Skip to content

road to reentrant real_path

Brandon Williams git 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest5 patches 5 repliesIn review
  2. v45 patches 9 repliesSuperseded
  3. v34 patches 10 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v24 patches7 repliesSuperseded

Changes in v5 from the cover letter

* 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.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5real_path: resolve symlinks by handabspath.c+133 -610 replies
2/5real_path: convert real_path_internal to strbuf_realpathabspath.c cache.h+27 -280 replies
3/5real_path: create real_pathdupabspath.c cache.h+14 -00 replies
4/5real_path: have callers use real_pathdup and strbuf_realpathbuiltin/init-db.c environment.c setup.c +4 more+16 -130 replies
5/5real_path: canonicalize directory separators in root partsabspath.c+17 -120 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/5] road to reentrant real_path

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

abspath.c +7 -3
index 3562d17bf..fce40fddc 100644
@@ -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;
 			}
Signature · 1 line
2.11.0.390.gc69c2f50cf-goog