Commit b3192f48 authored by Markus Klotzbuecher's avatar Markus Klotzbuecher Committed by Tom Rini
Browse files

moveconfig: replace unsafe eval with asteval

Commit b237d358

 ("moveconfig: expand simple expressions") added
support for expanding expressions in configs, but used the unsafe python
built-in "eval". This patch fixes this by replacing eval with the
asteval module.
Signed-off-by: default avatarMarkus Klotzbuecher <>
Cc: Heinrich Schuchardt <>
Cc: Heiko Schocher <>
Cc: Tom Rini <>
Cc: Simon Glass <>
Cc: Joe Hershberger <>
Cc: Masahiro Yamada <>
Reviewed-by: Heinrich Schuchardt's avatarHeinrich Schuchardt <>
parent 080cc0b1
......@@ -295,6 +295,7 @@ To see the complete list of supported options, run
import asteval
import collections
import copy
import difflib
......@@ -808,10 +809,11 @@ def try_expand(line):
return line
aeval = asteval.Interpreter( usersyms=SIZES, minimal=True )
cfg, val = re.split("=", line)
val= val.strip('\"')
if"[*+-/]|<<|SZ_+|\(([^\)]+)\)", val):
newval = hex(eval(val, SIZES))
newval = hex(aeval(val))
print("\tExpanded expression %s to %s" % (val, newval))
return cfg+'='+newval
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment