Check zbic's unpacked paths with is_relative_to, which a sibling folder cannot pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 05:57:21 -05:00
parent 41eacb97e8
commit 984a5f021a

View File

@@ -331,7 +331,7 @@ def ensure_zbic(layout, progress=None, cancel=None, log=print, version='dev'):
with zipfile.ZipFile(dest) as z:
for m in z.infolist():
target = (layout.pydeps / m.filename).resolve()
if not str(target).startswith(str(layout.pydeps.resolve())):
if not target.is_relative_to(layout.pydeps.resolve()): # not a sibling such as pydeps2 either
raise ToolchainError(f'{pick["filename"]}: unsafe path {m.filename}')
z.extractall(layout.pydeps)
dest.unlink(missing_ok=True)