Copy the local_vars dictionary to avoid eval modifying it

This avoid having the local_vars dictionary getting filled with
a large number of built-in variable that are of no use for this
dictionary.

This commit was created by from Alexander Larsson.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2021-09-14 11:19:42 +02:00 committed by Christian Kellner
parent 65b98448c6
commit 407bb73a12

3
tools/osbuild-mpp Normal file → Executable file
View file

@ -689,7 +689,8 @@ class ManifestFile:
format_string = node["mpp-format-int"]
# pylint: disable=eval-used # yolo this is fine!
res = eval(f'f\'\'\'{format_string}\'\'\'', local_vars)
# Note, we copy local_vars here to avoid eval modifying it
res = eval(f'f\'\'\'{format_string}\'\'\'', dict(local_vars))
if res_type == "int":
return int(res)