Fix Insecure temporary file

This commit is contained in:
Edgar 2021-03-01 09:14:25 +01:00
parent a6aa74f520
commit 6e76c46c4c
No known key found for this signature in database
GPG key ID: 8731E6C0166EAA85

View file

@ -55,7 +55,7 @@ class Dmgtools(Dmg):
def create(self, dmg, volume_name, directory, symlinks): def create(self, dmg, volume_name, directory, symlinks):
input_size = sum(os.stat(os.path.join(path, f)).st_size for path, dirs, files in os.walk(directory) for f in files) input_size = sum(os.stat(os.path.join(path, f)).st_size for path, dirs, files in os.walk(directory) for f in files)
output_size = max(input_size * 2, 1024**2) output_size = max(input_size * 2, 1024**2)
hfs = tempfile.mktemp(prefix=dmg + '.', suffix='.hfs') hfs = tempfile.mkstemp(prefix=dmg + '.', suffix='.hfs')
self._create_hfs(hfs, volume_name, output_size) self._create_hfs(hfs, volume_name, output_size)
self._add(hfs, directory) self._add(hfs, directory)
for target, link_name in symlinks: for target, link_name in symlinks: