Harden against large inline scripts
Can produce OSError 63 filename too long
This commit is contained in:
parent
5da29e1d9d
commit
f4308ac0c7
1 changed files with 12 additions and 4 deletions
|
@ -75,17 +75,25 @@ class PackageV1(Package):
|
|||
sum = sum.hexdigest()
|
||||
|
||||
installf = self.root / content
|
||||
if installf.exists():
|
||||
with open(installf, "r") as fp:
|
||||
self.do_sh_or_script(fp.read(), fs, dest)
|
||||
|
||||
elif content:
|
||||
def _installf_exists():
|
||||
try:
|
||||
return installf.exists()
|
||||
except OSError as e:
|
||||
return False
|
||||
|
||||
if content.startswith("#!") or "\n" in content or not _installf_exists():
|
||||
f = tempf(self.global_config, f"{sum}.sh")
|
||||
f.parent.mkdir(exist_ok=True, parents=True)
|
||||
with open(f, "w") as fp:
|
||||
fp.write(content)
|
||||
fs.exec(cwd, sh(self.global_config, [str(f)]))
|
||||
|
||||
else:
|
||||
with open(installf, "r") as fp:
|
||||
self.do_sh_or_script(fp.read(), fs, dest)
|
||||
|
||||
|
||||
def do_build(self, fs: Vfs, dest: Path):
|
||||
self.do_sh_or_script(self.config().get("package", {}).get("build"), fs, dest)
|
||||
|
||||
|
|
Loading…
Reference in a new issue