use os.sep instead of null byte to pad replacement paths in binaries (#15338)

* use os.sep instead of null byte to pad replacement paths in binaries

* Prefix the pading os.sep's
This commit is contained in:
Patrick Gartung 2020-03-04 17:15:09 -06:00 committed by GitHub
parent 8eda1db50f
commit 3ea0e91533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -412,7 +412,8 @@ def replace(match):
if padding < 0:
return data
return match.group().replace(old_dir.encode('utf-8'),
new_dir.encode('utf-8')) + b'\0' * padding
os.sep.encode('utf-8') * padding +
new_dir.encode('utf-8'))
with open(path_name, 'rb+') as f:
data = f.read()