##// END OF EJS Templates
subrepo: disallow symlink traversal across subrepo mount point (SEC)...
Yuya Nishihara -
r34985:071cbeba stable
parent child Browse files
Show More
@@ -359,6 +359,12 b' def _sanitize(ui, vfs, ignore):'
359 359 "in '%s'\n") % vfs.join(dirname))
360 360 vfs.unlink(vfs.reljoin(dirname, f))
361 361
362 def _auditsubrepopath(repo, path):
363 # auditor doesn't check if the path itself is a symlink
364 pathutil.pathauditor(repo.root)(path)
365 if repo.wvfs.islink(path):
366 raise error.Abort(_("subrepo '%s' traverses symbolic link") % path)
367
362 368 def subrepo(ctx, path, allowwdir=False, allowcreate=True):
363 369 """return instance of the right subrepo class for subrepo in path"""
364 370 # subrepo inherently violates our import layering rules
@@ -369,7 +375,7 b' def subrepo(ctx, path, allowwdir=False, '
369 375 from . import hg as h
370 376 hg = h
371 377
372 pathutil.pathauditor(ctx.repo().root)(path)
378 _auditsubrepopath(ctx.repo(), path)
373 379 state = ctx.substate[path]
374 380 if state[2] not in types:
375 381 raise error.Abort(_('unknown subrepo type %s') % state[2])
@@ -387,7 +393,7 b' def nullsubrepo(ctx, path, pctx):'
387 393 from . import hg as h
388 394 hg = h
389 395
390 pathutil.pathauditor(ctx.repo().root)(path)
396 _auditsubrepopath(ctx.repo(), path)
391 397 state = ctx.substate[path]
392 398 if state[2] not in types:
393 399 raise error.Abort(_('unknown subrepo type %s') % state[2])
@@ -50,17 +50,35 b' on commit:'
50 50 $ hg ci -qAm 'add symlink "out"'
51 51 $ hg init ../out
52 52 $ echo 'out = out' >> .hgsub
53 BROKEN: should fail
54 53 $ hg ci -qAm 'add subrepo "out"'
54 abort: subrepo 'out' traverses symbolic link
55 [255]
56
57 prepare tampered repo (including the commit above):
58
59 $ hg import --bypass -qm 'add subrepo "out"' - <<'EOF'
60 > diff --git a/.hgsub b/.hgsub
61 > new file mode 100644
62 > --- /dev/null
63 > +++ b/.hgsub
64 > @@ -0,0 +1,1 @@
65 > +out = out
66 > diff --git a/.hgsubstate b/.hgsubstate
67 > new file mode 100644
68 > --- /dev/null
69 > +++ b/.hgsubstate
70 > @@ -0,0 +1,1 @@
71 > +0000000000000000000000000000000000000000 out
72 > EOF
55 73 $ cd ../..
56 74
57 75 on clone (and update):
58 76
59 77 $ mkdir hgsymdir2
60 BROKEN: should fail to update
61 78 $ hg clone -q hgsymdir/root hgsymdir2/root
79 abort: subrepo 'out' traverses symbolic link
80 [255]
62 81 $ ls hgsymdir2
63 out
64 82 root
65 83
66 84 #endif
@@ -400,11 +400,13 b" Don't crash if the subrepo is missing"
400 400 Don't crash if subrepo is a broken symlink
401 401 $ ln -s broken s
402 402 $ hg status -S
403 abort: subrepo 's' traverses symbolic link
404 [255]
403 405 $ hg push -q
404 abort: subrepo s is missing (in subrepository "s")
406 abort: subrepo 's' traverses symbolic link
405 407 [255]
406 408 $ hg commit --subrepos -qm missing
407 abort: subrepo s is missing (in subrepository "s")
409 abort: subrepo 's' traverses symbolic link
408 410 [255]
409 411 $ rm s
410 412 #endif
General Comments 0
You need to be logged in to leave comments. Login now